7 years agoHEAD now requires GHC >= 7.0 to bootstrap
Ian Lynagh [Tue, 13 Dec 2011 19:54:08 +0000 (19:54 +0000)] 
HEAD now requires GHC >= 7.0 to bootstrap

7 years ago$(rts_H_FILES) should contain .h files in subdirectories of rts/ too
Simon Marlow [Tue, 13 Dec 2011 13:04:09 +0000 (13:04 +0000)] 
$(rts_H_FILES) should contain .h files in subdirectories of rts/ too

7 years agoFix for a bug in setNumCapabilities
Simon Marlow [Tue, 13 Dec 2011 13:03:44 +0000 (13:03 +0000)] 
Fix for a bug in setNumCapabilities

7 years agoFix for a bug in +RTS -qi (crash in zero_static_object_list)
Simon Marlow [Tue, 13 Dec 2011 13:03:23 +0000 (13:03 +0000)] 
Fix for a bug in +RTS -qi (crash in zero_static_object_list)

7 years agoadd a missing error check
Simon Marlow [Mon, 12 Dec 2011 16:29:03 +0000 (16:29 +0000)] 
add a missing error check

7 years agoAdd a comment about oddity with yieldThread() and timing results on Linux
Simon Marlow [Mon, 12 Dec 2011 16:28:29 +0000 (16:28 +0000)] 
Add a comment about oddity with yieldThread() and timing results on Linux

7 years agoTowards fixing Trac #5664
Simon Peyton Jones [Tue, 13 Dec 2011 13:36:34 +0000 (13:36 +0000)] 
Towards fixing Trac #5664

This patch makes normaliseFFIType recurse ito the arguments of FunPtr

7 years agoSpelling correction in comment
Simon Peyton Jones [Tue, 13 Dec 2011 13:34:58 +0000 (13:34 +0000)] 
Spelling correction in comment

7 years agoDocument typechecking of pattern bindings
Simon Peyton Jones [Tue, 13 Dec 2011 13:31:46 +0000 (13:31 +0000)] 
Document typechecking of pattern bindings

7 years agoDocument the "kind invariant", and check it
Simon Peyton Jones [Tue, 13 Dec 2011 12:30:40 +0000 (12:30 +0000)] 
Document the "kind invariant", and check it

See Note [The kind invariant] in TypeRep
Checked in CoreLint
All this arises from Trac #5426

7 years agoMerge branch 'master' of
Simon Peyton Jones [Tue, 13 Dec 2011 11:33:27 +0000 (11:33 +0000)] 
Merge branch 'master' of

7 years agoAvoid integer overflow when calling allocGroup() (#5071)
Simon Marlow [Mon, 12 Dec 2011 14:18:30 +0000 (14:18 +0000)] 
Avoid integer overflow when calling allocGroup() (#5071)

7 years agoNew flag +RTS -qi<n>, avoid waking up idle Capabilities to do parallel GC
Simon Marlow [Fri, 9 Dec 2011 10:35:46 +0000 (10:35 +0000)] 
New flag +RTS -qi<n>, avoid waking up idle Capabilities to do parallel GC

This is an experimental tweak to the parallel GC that avoids waking up
a Capability to do parallel GC if we know that the capability has been
idle for a (tunable) number of GC cycles.  The idea is that if you're
only using a few Capabilities, there's no point waking up the ones
that aren't busy.

e.g. +RTS -qi3

says "A Capability will participate in parallel GC if it was running
at all since the last 3 GC cycles."

Results are a bit hit and miss, and I don't completely understand why
yet.  Hence, for now it is turned off by default, and also not
documented except in the +RTS -? output.

7 years agowaitForGcThreads: should be calling interruptCapability(), not interruptAllCapabilities()
Simon Marlow [Mon, 12 Dec 2011 13:01:27 +0000 (13:01 +0000)] 
waitForGcThreads: should be calling interruptCapability(), not interruptAllCapabilities()

7 years agosome small optimisations
Simon Marlow [Fri, 9 Dec 2011 10:20:13 +0000 (10:20 +0000)] 
some small optimisations

7 years agoadd some SCCs
Simon Marlow [Fri, 9 Dec 2011 10:19:57 +0000 (10:19 +0000)] 
add some SCCs

7 years agoDo not emit the THREAD_RUNNABLE event; it has no useful semantic content
Simon Marlow [Wed, 7 Dec 2011 11:32:35 +0000 (11:32 +0000)] 
Do not emit the THREAD_RUNNABLE event; it has no useful semantic content

7 years agoCorrect tidying of VectInfo; fixes #5613
Manuel M T Chakravarty [Tue, 13 Dec 2011 04:09:54 +0000 (15:09 +1100)] 
Correct tidying of VectInfo; fixes #5613

7 years agoBump version number to 7.5
Ian Lynagh [Tue, 13 Dec 2011 01:33:51 +0000 (01:33 +0000)] 
Bump version number to 7.5

7 years agoAdd diff command to sync-all
Ian Lynagh [Mon, 12 Dec 2011 21:03:26 +0000 (21:03 +0000)] 
Add diff command to sync-all

7 years agoAdd comments about the meaning of can_fail and has_side_effects
Simon Peyton Jones [Mon, 12 Dec 2011 11:16:49 +0000 (11:16 +0000)] 
Add comments about the meaning of can_fail and has_side_effects

Taken from Trac #5658

7 years agoAdd a mutex around stg_sig_install
Simon Marlow [Mon, 12 Dec 2011 09:29:56 +0000 (09:29 +0000)] 
Add a mutex around stg_sig_install

Protects against a race when two threads call installHandler
simultaneously.  This was causing occasional failure of the test

7 years agoremove duplicate getStablePtr (already done in hs_init())
Simon Marlow [Mon, 12 Dec 2011 09:18:29 +0000 (09:18 +0000)] 
remove duplicate getStablePtr (already done in hs_init())

7 years agochange a contextSwitchCapability() to interruptCapability()
Simon Marlow [Mon, 12 Dec 2011 09:32:54 +0000 (09:32 +0000)] 
change a contextSwitchCapability() to interruptCapability()

7 years agoMake derived functor stuff watch out for type functions (Trac #5686)
Simon Peyton Jones [Mon, 12 Dec 2011 08:12:18 +0000 (08:12 +0000)] 
Make derived functor stuff watch out for type functions (Trac #5686)

The problem was simply that the side-condition check didn't test for a
type function, and then splitAppTy fell over.

7 years agoComments about orphans
Simon Peyton Jones [Mon, 12 Dec 2011 08:10:43 +0000 (08:10 +0000)] 
Comments about orphans

7 years agovectoriser: workaround bug in classiftTyCons
Ben Lippmeier [Mon, 12 Dec 2011 05:51:45 +0000 (16:51 +1100)] 
vectoriser: workaround bug in classiftTyCons

7 years agoAllow type signatures in instance decls (Trac #5676)
Simon Peyton Jones [Mon, 12 Dec 2011 00:32:06 +0000 (00:32 +0000)] 
Allow type signatures in instance decls (Trac #5676)

This new feature-ette, enable with -XInstanceSigs, lets
you give a type signature in an instance declaration:

   instance Eq Int where
     (==) :: Int -> Int -> Bool
     (==) = ...blah...

Scoped type variables work too.

7 years agoFix comment in CgMonad
David Terei [Sun, 11 Dec 2011 20:15:39 +0000 (12:15 -0800)] 
Fix comment in CgMonad

7 years agoRemove unused Interval module.
David Terei [Sun, 11 Dec 2011 20:07:31 +0000 (12:07 -0800)] 
Remove unused Interval module.

Patch from Michal Terepeta <>

7 years agoMerge branch 'master' of
David Terei [Sun, 11 Dec 2011 20:04:19 +0000 (12:04 -0800)] 
Merge branch 'master' of

7 years agoFix a real bug, exposed by my recent change to the rts_evalIO() API. Yay!
Simon Marlow [Fri, 9 Dec 2011 10:28:31 +0000 (10:28 +0000)] 
Fix a real bug, exposed by my recent change to the rts_evalIO() API.  Yay!

7 years agoFix Windows build
Simon Marlow [Fri, 9 Dec 2011 09:53:27 +0000 (09:53 +0000)] 
Fix Windows build

7 years agoMerge remote branch 'phonohawk/patch-5408'
Simon Marlow [Fri, 9 Dec 2011 10:33:45 +0000 (10:33 +0000)] 
Merge remote branch 'phonohawk/patch-5408'

* phonohawk/patch-5408:
  Resurrect UseLibFFIForAdjustors from bitrot.
  Detect cases where as(1) doesn't recognise .ident directive (#5408)

7 years agoFix silly bug in casMutVar#: I forgot the GC write barrier
Simon Marlow [Fri, 9 Dec 2011 09:09:42 +0000 (09:09 +0000)] 
Fix silly bug in casMutVar#: I forgot the GC write barrier

7 years agoMerge branch 'master' of
David Terei [Fri, 9 Dec 2011 00:15:26 +0000 (16:15 -0800)] 
Merge branch 'master' of

7 years agoResurrect UseLibFFIForAdjustors from bitrot.
PHO [Tue, 6 Dec 2011 14:15:35 +0000 (23:15 +0900)] 
Resurrect UseLibFFIForAdjustors from bitrot.

* Pass -Irts/dist/build to the C preprocessor to expose libffi headers (ffi.h and ffitarget.h) to foreign import wrappers during the building process of GHC itself.
* Install libffi headers into $(ghcheaderdir) just like any other C headers. Otherwise an installed GHC can't find them when it wants to compile foreign import wrappers.
* Include libffi headers in the bindist for the same reason.

7 years agoDetect cases where as(1) doesn't recognise .ident directive (#5408)
PHO [Wed, 30 Nov 2011 08:46:27 +0000 (17:46 +0900)] 
Detect cases where as(1) doesn't recognise .ident directive (#5408)

.ident directives are usually ignored by as(1), and in some cases (like Darwin/PPC) they even raise an error.

7 years agoDefine getNumberOfProcessors() even when !THREADED_RTS
Simon Marlow [Wed, 7 Dec 2011 15:46:27 +0000 (15:46 +0000)] 
Define getNumberOfProcessors() even when !THREADED_RTS

7 years agoImprove optimisation in the presence of SCCs (fixes #5363)
Simon Marlow [Wed, 7 Dec 2011 15:23:28 +0000 (15:23 +0000)] 
Improve optimisation in the presence of SCCs (fixes #5363)

We had some special cases to handle things like

  case (scc c (case E of alts)) of alts'

but it only worked when there was a single scc in the way.  This
generalises the optimisation to handle multiple sccs and ticks, so
that we can catch most case-of-case optimisations that would normally
apply in the absence of profiling.

This fixes the example in #5363, and nofib results (with -prof
-fprof-auto) show that allocation universally goes down or stays the

7 years agoTake into account -fprof-auto-*
Simon Marlow [Wed, 7 Dec 2011 15:11:37 +0000 (15:11 +0000)] 
Take into account -fprof-auto-*

8 years agoAdd new primtypes 'ArrayArray#' and 'MutableArrayArray#'
Manuel M T Chakravarty [Wed, 7 Dec 2011 11:40:14 +0000 (22:40 +1100)] 
Add new primtypes 'ArrayArray#' and 'MutableArrayArray#'

The primitive array types, such as 'ByteArray#', have kind #, but are represented by pointers. They are boxed, but unpointed types (i.e., they cannot be 'undefined').

The two categories of array types —[Mutable]Array# and [Mutable]ByteArray#— are containers for unboxed (and unpointed) as well as for boxed and pointed types.  So far, we lacked support for containers for boxed, unpointed types (i.e., containers for the primitive arrays themselves).  This is what the new primtypes provide.

Containers for boxed, unpointed types are crucial for the efficient implementation of scattered nested arrays, which are central to the new DPH backend library dph-lifted-vseg.  Without such containers, we cannot eliminate all unboxing from the inner loops of traversals processing scattered nested arrays.

8 years agoImprove the space usage of checkremove
Ian Lynagh [Wed, 7 Dec 2011 00:57:04 +0000 (00:57 +0000)] 
Improve the space usage of checkremove

Some of the nightly builders have been running out of memory when
running it.

8 years agoTabs -> Spaces + Formatting
David Terei [Tue, 6 Dec 2011 19:39:45 +0000 (11:39 -0800)] 
Tabs -> Spaces + Formatting

8 years agoAllow the number of capabilities to be increased at runtime (#3729)
Simon Marlow [Tue, 6 Dec 2011 15:12:07 +0000 (15:12 +0000)] 
Allow the number of capabilities to be increased at runtime (#3729)

At present the number of capabilities can only be *increased*, not
decreased.  The latter presents a few more challenges!

8 years agoMake forkProcess work with +RTS -N
Simon Marlow [Tue, 6 Dec 2011 11:38:07 +0000 (11:38 +0000)] 
Make forkProcess work with +RTS -N

Consider this experimental for the time being.  There are a lot of
things that could go wrong, but I've verified that at least it works
on the test cases we have.

I also did some API cleanups while I was here.  Previously we had:

Capability * rts_eval (Capability *cap, HaskellObj p, /*out*/HaskellObj *ret);

but this API is particularly error-prone: if you forget to discard the
Capability * you passed in and use the return value instead, then
you're in for subtle bugs with +RTS -N later on.  So I changed all
these functions to this form:

void rts_eval (/* inout */ Capability **cap,
               /* in    */ HaskellObj p,
               /* out */   HaskellObj *ret)

It's much harder to use this version incorrectly, because you have to
pass the Capability in by reference.

8 years agoFix #5658: mark all array indexing primops as can_fail
Ben Lippmeier [Tue, 29 Nov 2011 05:38:33 +0000 (16:38 +1100)] 
Fix #5658: mark all array indexing primops as can_fail

If they're not marked as can_fail, then they are floated out of case expressions that check whether the indices are in-bounds, causing immense suffering.

8 years agoCode generation: Always ask for result of newSpark
Peter Wortmann [Mon, 5 Dec 2011 21:32:19 +0000 (13:32 -0800)] 
Code generation: Always ask for result of newSpark

Otherwise the LLVM backend gets confused over whether its type should be
"void (i8*, i8*)" or "i64 (i8*, i8*)".

Signed-off-by: David Terei <>
8 years agoFix trac # 5486
David Terei [Tue, 6 Dec 2011 06:46:14 +0000 (22:46 -0800)] 
Fix trac # 5486

LLVM has a problem when the user imports some FFI types
like memcpy and memset in a manner that conflicts with
the types that GHC uses internally.

So now we pre-initialise the environment with the most
general types for these functions.

8 years agoMerge branch 'master' of
Simon Peyton Jones [Mon, 5 Dec 2011 04:49:28 +0000 (04:49 +0000)] 
Merge branch 'master' of

8 years agoMerge branch 'master' of ../HEAD
Simon Peyton Jones [Mon, 5 Dec 2011 04:46:15 +0000 (04:46 +0000)] 
Merge branch 'master' of ../HEAD

8 years agoAllow full constraint solving under a for-all (Trac #5595)
Simon Peyton Jones [Mon, 5 Dec 2011 04:44:13 +0000 (04:44 +0000)] 
Allow full constraint solving under a for-all (Trac #5595)

The main idea is that when we unify
    forall a. t1  ~  forall a. t2
we get constraints from unifying t1~t2 that mention a.
We are producing a coercion witnessing the equivalence of
the for-alls, and inside *that* coercion we need bindings
for the solved constraints arising from t1~t2.

We didn't have way to do this before.  The big change is
that here's a new type TcEvidence.TcCoercion, which is
much like Coercion.Coercion except that there's a slot
for TcEvBinds in it.

This has a wave of follow-on changes. Not deep but broad.

* New module TcEvidence, which now contains the HsWrapper
  TcEvBinds, EvTerm etc types that used to be in HsBinds

* The typechecker works exclusively in terms of TcCoercion.

* The desugarer converts TcCoercion to Coercion

* The main payload is in TcUnify.unifySigmaTy. This is the
  function that had a gross hack before, but is now beautiful.

* LCoercion is gone!  Hooray.

Many many fiddly changes in conssequence.  But it's nice.

8 years agoComments only: EqVar vs Covar
Simon Peyton Jones [Mon, 5 Dec 2011 04:01:36 +0000 (04:01 +0000)] 
Comments only: EqVar vs Covar

8 years agoMake TypeMap an instance of Outputable
Simon Peyton Jones [Mon, 5 Dec 2011 04:00:34 +0000 (04:00 +0000)] 
Make TypeMap an instance of Outputable

8 years agoMerge branch 'master' of
Ian Lynagh [Sun, 4 Dec 2011 15:34:59 +0000 (15:34 +0000)] 
Merge branch 'master' of

8 years agoClean includes/GHCConstants.h includes/DerivedConstants.h
Ian Lynagh [Sun, 4 Dec 2011 13:23:46 +0000 (13:23 +0000)] 
Clean includes/GHCConstants.h includes/DerivedConstants.h

We no longer generate them, but they may be in existing GHC trees,
so we'll keep cleaning them for a while.

8 years agoRemove unused import
Simon Peyton Jones [Sun, 4 Dec 2011 12:56:03 +0000 (12:56 +0000)] 
Remove unused import

8 years agoRemove dead function.
David Terei [Fri, 2 Dec 2011 23:52:32 +0000 (15:52 -0800)] 
Remove dead function.

8 years agoRemove old mangler comment
David Terei [Fri, 2 Dec 2011 23:52:22 +0000 (15:52 -0800)] 
Remove old mangler comment

8 years agoAdd SCC for LLVM code output
David Terei [Fri, 2 Dec 2011 23:52:00 +0000 (15:52 -0800)] 
Add SCC for LLVM code output

8 years agoFix ugly complexity issue in LLVM backend (#5652)
David Terei [Fri, 2 Dec 2011 23:48:43 +0000 (15:48 -0800)] 
Fix ugly complexity issue in LLVM backend (#5652)

Compile time still isn't as good as I'd like but no easy changes
available. LLVM backend could do with a big rewrite to improve
performance as there are some ugly designs in it.

At least the test case isn't 10min anymore, just a few seconds now.

8 years agoFormatt wibble
David Terei [Thu, 1 Dec 2011 22:25:43 +0000 (14:25 -0800)] 
Formatt wibble

8 years agoAdd CCS for llvm
David Terei [Thu, 1 Dec 2011 22:20:43 +0000 (14:20 -0800)] 
Add CCS for llvm

8 years agoRemove some unnecessary touch's
Ian Lynagh [Sat, 3 Dec 2011 00:34:30 +0000 (00:34 +0000)] 
Remove some unnecessary touch's

They made a dependency cycle in the rules used to build the touch
program on Windows.

8 years agoMerge branch 'master' of
Ian Lynagh [Fri, 2 Dec 2011 22:30:58 +0000 (22:30 +0000)] 
Merge branch 'master' of

8 years agoRemove unused install_headers and INSTALL_HEADERS
Ian Lynagh [Fri, 2 Dec 2011 22:25:52 +0000 (22:25 +0000)] 
Remove unused install_headers and INSTALL_HEADERS

8 years agoFix header installation
Ian Lynagh [Fri, 2 Dec 2011 22:24:27 +0000 (22:24 +0000)] 
Fix header installation

8 years agoMAKE_RESTARTS should never be higher than 1
Ian Lynagh [Fri, 2 Dec 2011 21:42:59 +0000 (21:42 +0000)] 
MAKE_RESTARTS should never be higher than 1

8 years agoMove includes/DerivedConstants.h and includes/GHCConstants.h into dist dirs
Ian Lynagh [Fri, 2 Dec 2011 21:35:18 +0000 (21:35 +0000)] 
Move includes/DerivedConstants.h and includes/GHCConstants.h into dist dirs

When they existed, they were getting included in the includes_H_FILES
variable (as it uses wildcard to find all header files). But the
.depends files for the programs that generate the headers depend on
$(includes_H_FILES), so the .depends files looked out-of-date once the
headers had been created. This caused unnecessary make reinvocations.

So now we put them in dist* directories, where they ought to be anyway.

8 years agoUse touchy rather than touch when building on Windows
Ian Lynagh [Fri, 2 Dec 2011 16:55:28 +0000 (16:55 +0000)] 
Use touchy rather than touch when building on Windows

With Windows 7 in a vitrual box VM on OS X, some very odd things happen
with dates and time stamps when SSHing into cygwin. e.g. here the
"Change" time is in the past:

$ date; touch foo; stat foo
Fri Dec  2 16:58:07 GMTST 2011
  File: `foo'
  Size: 0               Blocks: 0          IO Block: 65536  regular
empty file
Device: 540aba0bh/1409989131d   Inode: 562949953592977  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ian)   Gid: (  513/    None)
Access: 2011-12-02 16:58:07.414457900 +0000
Modify: 2011-12-02 16:58:07.414457900 +0000
Change: 2011-12-02 16:58:03.495141800 +0000
 Birth: 2011-12-02 16:57:57.731469900 +0000

And if we copy such a file, then the copy is older (as determined by the
"Modify" time) than the original:

$ date; touch foo; stat foo; cp foo bar; stat bar
Fri Dec  2 16:59:10 GMTST 2011
  File: `foo'
  Size: 0               Blocks: 0          IO Block: 65536  regular
empty file
Device: 540aba0bh/1409989131d   Inode: 1407374883725128  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ian)   Gid: (  513/    None)
Access: 2011-12-02 16:59:10.118457900 +0000
Modify: 2011-12-02 16:59:10.118457900 +0000
Change: 2011-12-02 16:59:06.189477700 +0000
 Birth: 2011-12-02 16:57:57.731469900 +0000
  File: `bar'
  Size: 0               Blocks: 0          IO Block: 65536  regular
empty file
Device: 540aba0bh/1409989131d   Inode: 281474976882512  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ian)   Gid: (  513/    None)
Access: 2011-12-02 16:59:06.394555800 +0000
Modify: 2011-12-02 16:59:06.394555800 +0000
Change: 2011-12-02 16:59:06.395532400 +0000
 Birth: 2011-12-02 16:58:40.921899600 +0000

This means that make thinks that things are out of date when it
shouldn't, so reinvokes itself repeatedly until the MAKE_RESTARTS
infinite-recursion test triggers.

The touchy program, like most other programs, creates files with both
Modify and Change in the past, which is still a little odd, but is
consistent, so doesn't break make.

8 years agoMore changes aimed at improving call stacks.
Simon Marlow [Fri, 2 Dec 2011 13:09:14 +0000 (13:09 +0000)] 
More changes aimed at improving call stacks.

  - Attach a SrcSpan to every CostCentre.  This had the side effect
    that CostCentres that used to be merged because they had the same
    name are now considered distinct; so I had to add a Unique to
    CostCentre to give them distinct object-code symbols.

  - New flag: -fprof-auto-calls.  This flag adds an automatic SCC to
    every call site (application, to be precise).  This is typically
    more useful for call stacks than annotating whole functions.

Various tidy-ups at the same time: removed unused NoCostCentre
constructor, and refactored a bit in Coverage.lhs.

The call stack we get from traceStack now looks like this:

Stack trace:
  Main.CAF (<entire-module>)
  Main.main.xs (callstack002.hs:18:12-24) (callstack002.hs:13:12-16) (callstack002.hs:15:21-34) (callstack002.hs:15:21-23)
  Main.f (callstack002.hs:10:7-43)

8 years agoremove unused coreExprCc
Simon Marlow [Fri, 2 Dec 2011 09:33:14 +0000 (09:33 +0000)] 
remove unused coreExprCc

8 years agoForgot an initMutex(); fixes profthreaded failures on Windows
Simon Marlow [Thu, 1 Dec 2011 11:56:39 +0000 (11:56 +0000)] 
Forgot an initMutex(); fixes profthreaded failures on Windows

8 years agoFix a scheduling bug in the threaded RTS
Simon Marlow [Thu, 1 Dec 2011 10:53:28 +0000 (10:53 +0000)] 
Fix a scheduling bug in the threaded RTS

The parallel GC was using setContextSwitches() to stop all the other
threads, which sets the context_switch flag on every Capability.  That
had the side effect of causing every Capability to also switch
threads, and since GCs can be much more frequent than context
switches, this increased the context switch frequency.  When context
switches are expensive (because the switch is between two bound
threads or a bound and unbound thread), the difference is quite

The fix is to have a separate flag to indicate that a Capability
should stop and return to the scheduler, but not switch threads.  I've
called this the "interrupt" flag.

8 years agoloadArchive: need to allocate executable memory on Win32 (#5371)
Simon Marlow [Wed, 30 Nov 2011 15:34:00 +0000 (15:34 +0000)] 
loadArchive: need to allocate executable memory on Win32 (#5371)

8 years agoFix potential crash on Windows: off-by-one in malloc()
Simon Marlow [Wed, 30 Nov 2011 15:25:57 +0000 (15:25 +0000)] 
Fix potential crash on Windows: off-by-one in malloc()

Spotted by gdb's malloc debugger while I was looking for something else.

8 years agoAdd missing newline in RTS help output.
Edward Z. Yang [Thu, 1 Dec 2011 06:27:12 +0000 (01:27 -0500)] 
Add missing newline in RTS help output.

Signed-off-by: Edward Z. Yang <>
8 years agoFix parsing of OPTIONS*/LANGUAGE pragmas in haddock mode
Ian Lynagh [Wed, 30 Nov 2011 22:49:05 +0000 (22:49 +0000)] 
Fix parsing of OPTIONS*/LANGUAGE pragmas in haddock mode

When getting options from basicTypes/RdrName.lhs, we were seeing
text like "-- |\n-- ...\n" in the buffer, and lexer then recognises
"-- |\n-- ..." as a complete ITdocCommentNext token, with the end of
the buffer not reached.

Next time round, when we get more input into the buffer, it started
"\n-- * 'Var.Var': see", so the lexer gave us an ITdocSection token.

However, getOptions' only knew about ITdocCommentNext, and so it
stopped at that point, and didn't see the pragmas further down the file.
This caused the build to fail due to -fwarn-tabs not being turned off.

But actually, we don't really want the haddock docs at this point, so
now we just unset Opt_Haddock in getOptionsFromFile.

8 years agoFix cmd invocation by libffi cuild system on Windows 7 cygwin
Ian Lynagh [Wed, 30 Nov 2011 17:53:08 +0000 (17:53 +0000)] 
Fix cmd invocation by libffi cuild system on Windows 7 cygwin

8 years agoInclude a stack trace in the panic message, when GHC is compiled profiled.
Simon Marlow [Wed, 30 Nov 2011 11:32:23 +0000 (11:32 +0000)] 
Include a stack trace in the panic message, when GHC is compiled profiled.

I tried this out on the panic we're currently getting for #3103:

ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.3.20111128 for x86_64-unknown-linux):
        tcIfaceGlobal (local): not found:
    base:GHC.Word.W#{d 6w}
    [(32R, Type constructor `base:GHC.Word.Word{tc 32R}'),
     (r6O, Identifier `base:GHC.Word.$fNumWord{v r6O}'),
     (r6P, Identifier `base:GHC.Word.$fEqWord{v r6P}'),
     (r6Q, Identifier `base:GHC.Word.$fNumWord1{v r6Q}'),
     (r6R, Identifier `base:GHC.Word.$fNumWord2{v r6R}'),
     (r6S, Data constructor `base:GHC.Word.W#{d r6S}'),
     (r6U, Identifier `base:GHC.Word.W#{v r6U}'),
     (r75, Identifier `base:GHC.Word.$fNumWord_$csignum{v r75}'),
     (r76, Identifier `base:GHC.Word.$fEqWord_$c/={v r76}'),
     (r77, Identifier `base:GHC.Word.$fEqWord_$c=={v r77}')]
{ Main.main
                                  TcIface.tcIfaceDataCon }

8 years agoFurther tweaks to the ccs primops
Simon Marlow [Wed, 30 Nov 2011 10:33:47 +0000 (10:33 +0000)] 
Further tweaks to the ccs primops

 - add getCCSOf# :: a -> State# s -> (# State# s, Addr# #)
   (returns the CCS attached to the supplied object)

 - remove traceCcs# (obsoleted by getCCSOf#)

 - rename getCCCS# to getCurrentCCS#

8 years agoremove obsolete notes (#5660)
Simon Marlow [Wed, 30 Nov 2011 08:52:38 +0000 (08:52 +0000)] 
remove obsolete notes (#5660)

8 years agoTurn a bunch of ints into longs to avoid overflow (#5656)
Simon Marlow [Tue, 29 Nov 2011 16:05:05 +0000 (16:05 +0000)] 
Turn a bunch of ints into longs to avoid overflow (#5656)

8 years agoMerge branch 'master' of
Ian Lynagh [Wed, 30 Nov 2011 02:26:13 +0000 (02:26 +0000)] 
Merge branch 'master' of

8 years agoFix libffi depfile creation on Windows: Use -MD rather than -MMD
Ian Lynagh [Wed, 30 Nov 2011 02:24:33 +0000 (02:24 +0000)] 
Fix libffi depfile creation on Windows: Use -MD rather than -MMD

8 years agoMerge branch 'master' of
Simon Peyton Jones [Wed, 30 Nov 2011 01:01:34 +0000 (01:01 +0000)] 
Merge branch 'master' of

8 years agoMerge branch 'master' of
Simon Peyton Jones [Tue, 29 Nov 2011 19:33:48 +0000 (19:33 +0000)] 
Merge branch 'master' of

8 years agoImprove the checkremove util
Ian Lynagh [Sun, 27 Nov 2011 21:27:34 +0000 (21:27 +0000)] 
Improve the checkremove util

We now put the before and after filenames into a tree structure,
which vastly improves performance when simulating the delete

8 years agoMerge branch 'master' of
Dimitrios Vytiniotis [Tue, 29 Nov 2011 19:20:33 +0000 (19:20 +0000)] 
Merge branch 'master' of

8 years agoInsufficient rewriting during flattening. This fixes #5668.
Dimitrios Vytiniotis [Tue, 29 Nov 2011 19:15:17 +0000 (19:15 +0000)] 
Insufficient rewriting during flattening. This fixes #5668.

8 years agoMerge branch 'master' of
Simon Peyton Jones [Tue, 29 Nov 2011 15:50:12 +0000 (15:50 +0000)] 
Merge branch 'master' of

8 years agoRefactor (again) the treatment of record-selector bindings
Simon Peyton Jones [Tue, 29 Nov 2011 15:49:24 +0000 (15:49 +0000)] 
Refactor (again) the treatment of record-selector bindings

We were generating them from the tcg_tcs field of the TcGblEnv,
but that goes badly wrong when there are top-level Template
Haskell splices, because the tcg_tcs field grows successively.
If we generate record-selector binds for all the TyCons in the
accumulated list, we generate them multiple times for TyCons
earlier in the program.  This what was happening in Trac #5665:
  data T = T { x :: Int }
  $(f 4)  -- Top level splice
  ..more code..
Here the record selector bindings for T were being generated

Better instead to generate the record-selector bindings in
TcTyClsDecls, right where the new TyCons are being declared (as indeed
they were some time ago).  This pushed me into doing some refactoring:
instead of returning the record bindings, tcTyAndClassDecls adds them
to the tcg_binds field of the TcGblEnv.  I think the result is a bit
nicer, and it has the additional merit of working.

8 years agoAdd a new primop: getCCCS# :: State# s -> (# State# s, Addr# #)
Simon Marlow [Tue, 29 Nov 2011 14:05:17 +0000 (14:05 +0000)] 
Add a new primop: getCCCS# :: State# s -> (# State# s, Addr# #)

Returns a pointer to the current cost-centre stack when profiling,
NULL otherwise.

8 years agodoc update: -prof now works with +RTS -N (with caveats)
Simon Marlow [Tue, 29 Nov 2011 13:05:48 +0000 (13:05 +0000)] 
doc update: -prof now works with +RTS -N (with caveats)

8 years agoAnother fix to the stg_enter_checkbh frame
Simon Marlow [Tue, 29 Nov 2011 12:43:45 +0000 (12:43 +0000)] 
Another fix to the stg_enter_checkbh frame

8 years agoMake profiling work with multiple capabilities (+RTS -N)
Simon Marlow [Mon, 28 Nov 2011 16:48:43 +0000 (16:48 +0000)] 
Make profiling work with multiple capabilities (+RTS -N)

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).

8 years agoWhite space only
Simon Peyton Jones [Tue, 29 Nov 2011 11:00:32 +0000 (11:00 +0000)] 
White space only

8 years agostg_enter_checkbh: fix offsets for profiling
Simon Marlow [Mon, 28 Nov 2011 16:27:26 +0000 (16:27 +0000)] 
stg_enter_checkbh: fix offsets for profiling

8 years agoGet rid of the "safety" field of CmmCall (OldCmm)
Simon Marlow [Mon, 28 Nov 2011 16:32:50 +0000 (16:32 +0000)] 
Get rid of the "safety" field of CmmCall (OldCmm)

This field was doing nothing.  I think it originally appeared in a
very old incarnation of the new code generator.

8 years agoSwitch around the order of guards in exprIsConApp_maybe
Simon Peyton Jones [Tue, 29 Nov 2011 07:39:04 +0000 (07:39 +0000)] 
Switch around the order of guards in exprIsConApp_maybe

This is a vital wibble to:
 f7cf3dcd * Be a bit less gung-ho in exprIsConApp_maybe