ghc.git
10 years agoAdd a size-comparison util
Ian Lynagh [Tue, 15 Dec 2009 20:26:36 +0000 (20:26 +0000)] 
Add a size-comparison util

10 years agoJust make C dependencies once, rather than each way
Ian Lynagh [Tue, 15 Dec 2009 13:53:50 +0000 (13:53 +0000)] 
Just make C dependencies once, rather than each way
This makes generating C dependencies for the RTS take 3 seconds, rather
than 30.

10 years agoMake addCFileDeps quieter
Ian Lynagh [Tue, 15 Dec 2009 13:40:33 +0000 (13:40 +0000)] 
Make addCFileDeps quieter
Move a comment out of the definition, so it doesn't get printed as
a shell command every time we call the definition

10 years agoDon't make C deps for compiler/parser/cutils.c in stage1
Ian Lynagh [Tue, 15 Dec 2009 12:37:57 +0000 (12:37 +0000)] 
Don't make C deps for compiler/parser/cutils.c in stage1
CPP finds the Rts.h, RtsFlags.h etc from the tree, rather than the
bootstrapping compiler, and then fails because it doesn't think
RtsFlags.h should be used any more.

10 years agoTidy up computation of result discounts in CoreUnfold
simonpj@microsoft.com [Mon, 14 Dec 2009 13:46:47 +0000 (13:46 +0000)] 
Tidy up computation of result discounts in CoreUnfold

Mostly this patch is a tidy-up, but it did reveal one inconsistency
that I fixed.  When computing result discounts for case expressions,
we were *adding* result-discounts for cases on non-arguments, but
*picking the one for the max-size branch* for arguments. I think you
could argue the toss, but it seems neater (and the code is nicer)
to be consistent (ie always add).  See Note [addAltSize result discounts].

The nofib results seem fine

        Program           Size    Allocs   Runtime   Elapsed
--------------------------------------------------------------------------------
          boyer          -0.8%     -4.8%      0.06      0.07
         sphere          -0.7%     -2.5%      0.15      0.16
--------------------------------------------------------------------------------
            Min          -0.8%     -4.8%    -19.1%    -24.8%
            Max          -0.5%     +0.0%     +3.4%   +127.1%
 Geometric Mean          -0.7%     -0.1%     -4.3%     -1.3%

The +127% elapsed is a timing error; I re-ran the same binary and it's
unchanged from the baseline.

10 years agoUse full equality for CSE
simonpj@microsoft.com [Fri, 11 Dec 2009 17:39:20 +0000 (17:39 +0000)] 
Use full equality for CSE

In CSE we were getting lots of apprarently-unequal expressions with
the same hash code.  In fact they were perfectly equal -- but we were
using a cheap-and-cheerful equality tests for CoreExpr that said False
for any lambda expression!

This patch adds a proper equality test for Core, with alpha-renaming.
It's easy to do, and will avoid silly cases of CSE failing to fire.

We should get less of this:
  WARNING: file compiler/simplCore/CSE.lhs line 326
  extendCSEnv: long list, length 18
from a compiler built with -DDEBUG

10 years agoImprove strictness analysis for bottoming functions
simonpj@microsoft.com [Fri, 11 Dec 2009 16:23:24 +0000 (16:23 +0000)] 
Improve strictness analysis for bottoming functions

I found the following results from strictness analyis:
  f x = error (fst x)      -- Strictness U(SA)b
  g x = error ('y':fst x)  -- Strictness Tb

Surely 'g' is no less strict on 'x' than 'f' is!  The fix turned out
be to very nice and simple.  See Note [Bottom demands] in DmdAnal.

10 years agoBottom extraction: float out bottoming expressions to top level
simonpj@microsoft.com [Fri, 11 Dec 2009 16:19:28 +0000 (16:19 +0000)] 
Bottom extraction: float out bottoming expressions to top level

The idea is to float out bottoming expressions to top level,
abstracting them over any variables they mention, if necessary.  This
is good because it makes functions smaller (and more likely to
inline), by keeping error code out of line.

See Note [Bottoming floats] in SetLevels.

On the way, this fixes the HPC failures for cg059 and friends.

I've been meaning to do this for some time.  See Maessen's paper 1999
"Bottom extraction: factoring error handling out of functional
programs" (unpublished I think).

Here are the nofib results:

        Program           Size    Allocs   Runtime   Elapsed
--------------------------------------------------------------------------------
            Min          +0.1%     -7.8%    -14.4%    -32.5%
            Max          +0.5%     +0.2%     +1.6%    +13.8%
 Geometric Mean          +0.4%     -0.2%     -4.9%     -6.7%

Module sizes
        -1 s.d.                -----           -2.6%
        +1 s.d.                -----           +2.3%
        Average                -----           -0.2%

Compile times:
        -1 s.d.                -----          -11.4%
        +1 s.d.                -----           +4.3%
        Average                -----           -3.8%

I'm think program sizes have crept up because the base library
is bigger -- module sizes in nofib decrease very slightly.  In turn
I think that may be because the floating generates a call where
there was no call before.  Anyway I think it's acceptable.

The main changes are:

* SetLevels floats out things that exprBotStrictness_maybe
  identifies as bottom.  Make sure to pin on the right
  strictness info to the newly created Ids, so that the
  info ends up in interface files.

  Since FloatOut is run twice, we have to be careful that we
  don't treat the function created by the first float-out as
  a candidate for the second; this is what worthFloating does.

  See SetLevels Note [Bottoming floats]
                Note [Bottoming floats: eta expansion]

* Be careful not to inline top-level bottoming functions; this
  would just undo what the floating transformation achieves.
  See CoreUnfold Note [Do not inline top-level bottoming functions

  Ensuring this requires a bit of extra plumbing, but nothing drastic..

* Similarly pre/postInlineUnconditionally should be
  careful not to re-inline top-level bottoming things!
  See SimplUtils Note [Top-level botomming Ids]
                 Note [Top level and postInlineUnconditionally]

10 years agoExpose all EventLog events as DTrace probes
Manuel M T Chakravarty [Sat, 12 Dec 2009 10:08:09 +0000 (10:08 +0000)] 
Expose all EventLog events as DTrace probes
- Defines a DTrace provider, called 'HaskellEvent', that provides a probe
  for every event of the eventlog framework.
- In contrast to the original eventlog, the DTrace probes are available in
  all flavours of the runtime system (DTrace probes have virtually no
  overhead if not enabled); when -DTRACING is defined both the regular
  event log as well as DTrace probes can be used.
- Currently, Mac OS X only.  User-space DTrace probes are implemented
  differently on Mac OS X than in the original DTrace implementation.
  Nevertheless, it shouldn't be too hard to enable these probes on other
  platforms, too.
- Documentation is at http://hackage.haskell.org/trac/ghc/wiki/DTrace

10 years agoFix two related bugs in u_tys
simonpj@microsoft.com [Fri, 11 Dec 2009 12:01:22 +0000 (12:01 +0000)] 
Fix two related bugs in u_tys

When we normalise a type family application we must recursively call
uTys, *not* 'go', because the latter loop is only there to look
through type synonyms.  This bug made the type checker generate
ill-typed coercions, which were rejected by Core Lint.

A related bug only affects the size of coercions.  If faced with
  (m a) ~ (F b c)
where F has arity 1, we want to decompose to
   m ~ F Int,  a ~ c
rather than deferring.  The application decomposition was being
tried last, so we were missing this opportunity.

Thanks to Roman for an example that showed all this up.

10 years agoFix spelling in comment
simonpj@microsoft.com [Fri, 11 Dec 2009 11:57:44 +0000 (11:57 +0000)] 
Fix spelling in comment

10 years agoMake -ddump-simpl-stats a bit more informative by default
simonpj@microsoft.com [Tue, 8 Dec 2009 17:54:45 +0000 (17:54 +0000)] 
Make -ddump-simpl-stats a bit more informative by default

This mades -ddump-simpl-stats print out per-rule and per-id
information by default, rather than requiring -dppr-debug.
On the whole that is what you want.  The -dppr-debug flag
now just controls printing of the log.

10 years agoImprove dumping for rules, and documentation of same
simonpj@microsoft.com [Tue, 8 Dec 2009 10:55:56 +0000 (10:55 +0000)] 
Improve dumping for rules, and documentation of same

Inspired by Trac #3703

10 years agoFix #3741, simplifying things in the process
Simon Marlow [Thu, 10 Dec 2009 16:09:09 +0000 (16:09 +0000)] 
Fix #3741, simplifying things in the process
The problem in #3741 was that we had confused column numbers with byte
offsets, which fails in the case of UTF-8 (amongst other things).
Fortunately we're tracking correct column offsets now, so we didn't
have to make a calculation based on a byte offset.  I got rid of two
fields from the PState (last_line_len and last_offs).and one field
from the AI (alex input) constructor.

10 years agoAllow spaces at either end of the C import spec (#3742)
Simon Marlow [Thu, 10 Dec 2009 12:45:37 +0000 (12:45 +0000)] 
Allow spaces at either end of the C import spec (#3742)

10 years agoPut README and INSTALL into bindists
Ian Lynagh [Wed, 9 Dec 2009 17:43:05 +0000 (17:43 +0000)] 
Put README and INSTALL into bindists
Also tidied up the way configure.ac gets into bindists

10 years agoFix typo
Ian Lynagh [Wed, 9 Dec 2009 15:22:23 +0000 (15:22 +0000)] 
Fix typo

10 years agoFix the stage1 version number munging
Ian Lynagh [Wed, 9 Dec 2009 15:17:15 +0000 (15:17 +0000)] 
Fix the stage1 version number munging
It was munging 6.12.1 into 62

10 years agoAdd a comment about why $(CPP) is defined the way it is in config.mk.in
Ian Lynagh [Wed, 9 Dec 2009 13:19:17 +0000 (13:19 +0000)] 
Add a comment about why $(CPP) is defined the way it is in config.mk.in

10 years agoadd a missing unlockTSO()
Simon Marlow [Wed, 9 Dec 2009 12:41:13 +0000 (12:41 +0000)] 
add a missing unlockTSO()

10 years agoEliminate mkdependC
Ian Lynagh [Wed, 9 Dec 2009 12:39:29 +0000 (12:39 +0000)] 
Eliminate mkdependC
We now just call gcc to get the dependencies directly

10 years agoChange some HC_OPTS to CC_OPTS, so they are used when making dependencies
Ian Lynagh [Tue, 8 Dec 2009 20:03:15 +0000 (20:03 +0000)] 
Change some HC_OPTS to CC_OPTS, so they are used when making dependencies

10 years agoAdd -Iincludes to hp2ps's CC_OPTS
Ian Lynagh [Tue, 8 Dec 2009 17:57:18 +0000 (17:57 +0000)] 
Add -Iincludes to hp2ps's CC_OPTS
Making C deps for hp2ps always failed, but we used to carry on regardless

10 years agoadd locking in mkWeakForeignEnv#
Simon Marlow [Tue, 8 Dec 2009 10:12:29 +0000 (10:12 +0000)] 
add locking in mkWeakForeignEnv#

10 years agodeclare g0 (fixes compilation failure with -fvia-C)
Simon Marlow [Tue, 8 Dec 2009 10:09:25 +0000 (10:09 +0000)] 
declare g0 (fixes compilation failure with -fvia-C)

10 years agosimplify weak pointer processing
Simon Marlow [Tue, 8 Dec 2009 09:48:22 +0000 (09:48 +0000)] 
simplify weak pointer processing

10 years agosimplification/optimisation: update tso->bound->tso when scavenging the TSO
Simon Marlow [Tue, 8 Dec 2009 08:57:39 +0000 (08:57 +0000)] 
simplification/optimisation: update tso->bound->tso when scavenging the TSO

10 years agothreadStackUnderflow: fix recently introduced bug (conc068(threaded1) failure)
Simon Marlow [Mon, 7 Dec 2009 17:01:27 +0000 (17:01 +0000)] 
threadStackUnderflow: fix recently introduced bug (conc068(threaded1) failure)

bug introduced by "threadStackUnderflow: put the new TSO on the mut
list if necessary"

10 years agoneed locking around use of weak_ptr_list in mkWeak#
Simon Marlow [Mon, 7 Dec 2009 14:52:13 +0000 (14:52 +0000)] 
need locking around use of weak_ptr_list in mkWeak#

10 years agoremove global 'total_allocated', seems to be the same as 'GC_tot_alloc'
Simon Marlow [Mon, 7 Dec 2009 11:53:59 +0000 (11:53 +0000)] 
remove global 'total_allocated', seems to be the same as 'GC_tot_alloc'

10 years agoAdd some explanation about overlapping instances
simonpj@microsoft.com [Mon, 7 Dec 2009 15:39:15 +0000 (15:39 +0000)] 
Add some explanation about overlapping instances

Trac #3734 suggested addding some extra guidance about
incoherence and overlap; now done

10 years agoTidy up deriving error messages
simonpj@microsoft.com [Mon, 7 Dec 2009 13:08:50 +0000 (13:08 +0000)] 
Tidy up deriving error messages

I did this in response to a suggestion in Trac #3702

10 years agoFix profiling build
Simon Marlow [Mon, 7 Dec 2009 09:23:14 +0000 (09:23 +0000)] 
Fix profiling build

10 years agoMinor refactoring to remove redundant code
simonpj@microsoft.com [Mon, 7 Dec 2009 08:33:12 +0000 (08:33 +0000)] 
Minor refactoring to remove redundant code

10 years agoFix a nasty (and long-standing) FloatOut performance bug
simonpj@microsoft.com [Mon, 7 Dec 2009 08:32:46 +0000 (08:32 +0000)] 
Fix a nasty (and long-standing) FloatOut performance bug

The effect was that, in deeply-nested applications, FloatOut would
take quadratic time.  A good example was compiling
    programs/barton-mangler-bug/Expected.hs
in which FloatOut had a visible pause of a couple of seconds!
Profiling showed that 40% of the entire compile time was being
consumbed by the single function partitionByMajorLevel.

The bug was that the floating bindings (type FloatBinds) was kept
as a list, which was partitioned at each binding site.  In programs
with deeply nested lists, such as
       e1 : e2 : e3 : .... : e5000 : []
this led to quadratic behaviour.

The solution is to use a proper finite-map representation;
see the new definition of FloatBinds near the bottom of FloatOut.

10 years agoAdd a new to-do to cmm-notes
simonpj@microsoft.com [Mon, 7 Dec 2009 08:11:30 +0000 (08:11 +0000)] 
Add a new to-do to cmm-notes

10 years agoComments only, principally about IfaceDeclExtras
simonpj@microsoft.com [Mon, 7 Dec 2009 08:11:08 +0000 (08:11 +0000)] 
Comments only, principally about IfaceDeclExtras

10 years agoComments only, about RULE plumbing
simonpj@microsoft.com [Mon, 7 Dec 2009 08:04:42 +0000 (08:04 +0000)] 
Comments only, about RULE plumbing

10 years agoAdd splitUFM to UniqFM (used in a forthcoming patch)
simonpj@microsoft.com [Fri, 4 Dec 2009 16:08:20 +0000 (16:08 +0000)] 
Add splitUFM to UniqFM (used in a forthcoming patch)

splitUFM :: Uniquable key => UniqFM elt -> key -> (UniqFM elt, Maybe elt, UniqFM elt)
   -- Splits a UFM into things less than, equal to, and greater than the key

10 years agoAdd lengthBag to Bag (using in forthcoming patch)
simonpj@microsoft.com [Fri, 4 Dec 2009 15:50:55 +0000 (15:50 +0000)] 
Add lengthBag to Bag (using in forthcoming patch)

10 years agoUse addToUFM_Acc where appropriate
simonpj@microsoft.com [Fri, 4 Dec 2009 15:50:36 +0000 (15:50 +0000)] 
Use addToUFM_Acc where appropriate

This way of extending a UniqFM has existed for some time, but
we weren't really using it.

addToUFM_Acc :: Uniquable key =>
      (elt -> elts -> elts) -- Add to existing
   -> (elt -> elts) -- New element
   -> UniqFM elts  -- old
   -> key -> elt  -- new
   -> UniqFM elts -- result

10 years agoAdd comments to "OPTIONS_GHC -fno-warn-orphans" pragmas
Ian Lynagh [Sat, 5 Dec 2009 16:57:21 +0000 (16:57 +0000)] 
Add comments to "OPTIONS_GHC -fno-warn-orphans" pragmas

10 years agoAdd some missing exports back for GHC package users; fixes trac #3715
Ian Lynagh [Sat, 5 Dec 2009 15:35:32 +0000 (15:35 +0000)] 
Add some missing exports back for GHC package users; fixes trac #3715

10 years agoAdd some comments on the alternative layout rule state
Ian Lynagh [Sat, 5 Dec 2009 15:20:39 +0000 (15:20 +0000)] 
Add some comments on the alternative layout rule state

10 years agoTweak layout for alternative layout rule
Ian Lynagh [Thu, 3 Dec 2009 16:44:24 +0000 (16:44 +0000)] 
Tweak layout for alternative layout rule

10 years agoLink all dynamic libraries with the correct install_name on Mac OS/X.
Ian Lynagh [Fri, 4 Dec 2009 14:36:14 +0000 (14:36 +0000)] 
Link all dynamic libraries with the correct install_name on Mac OS/X.
This is a rerecord of
    Stephen Blackheath <oversensitive.pastors.stephen@blacksapphire.com>**20090930222855
to avoid conflicts.

10 years agoDocument the new -dylib-install-name option in the user's guide.
Stephen Blackheath [Thu, 1 Oct 2009 05:16:37 +0000 (05:16 +0000)] 
Document the new -dylib-install-name option in the user's guide.

10 years agoAdd -dylib-install-name option to GHC so the install name can be set for dynamic...
Stephen Blackheath [Wed, 30 Sep 2009 22:37:08 +0000 (22:37 +0000)] 
Add -dylib-install-name option to GHC so the install name can be set for dynamic libs on Mac OS/X.

10 years agoForce -fPIC when linking against dynamic libraries on Mac OS/X.
Stephen Blackheath [Mon, 28 Sep 2009 20:38:00 +0000 (20:38 +0000)] 
Force -fPIC when linking against dynamic libraries on Mac OS/X.
Otherwise you get
/tmp/ghc7602_0/ghc7602_0.s:207:0:
   non-relocatable subtraction expression, "___stginit_Lib_dyn" minus "L1x2;4"
/tmp/ghc7602_0/ghc7602_0.s:207:0:
   symbol: "___stginit_Lib_dyn" can't be undefined in a subtraction expression

10 years agoevaluate_large: evaluate large objects to bd->dest rather than gen->to
Simon Marlow [Fri, 4 Dec 2009 11:10:37 +0000 (11:10 +0000)] 
evaluate_large: evaluate large objects to bd->dest rather than gen->to
This fixes aging of large objects in the new scheme.  Bug found by
perf/space_leaks/space_leak_001.  Yay perf regressions tests.

10 years agoCorrection to the allocation stats following earlier refactoring
Simon Marlow [Fri, 4 Dec 2009 11:08:39 +0000 (11:08 +0000)] 
Correction to the allocation stats following earlier refactoring

10 years agoexport g0
Simon Marlow [Thu, 3 Dec 2009 16:52:09 +0000 (16:52 +0000)] 
export g0

10 years agoGC refactoring, remove "steps"
Simon Marlow [Thu, 3 Dec 2009 15:07:28 +0000 (15:07 +0000)] 
GC refactoring, remove "steps"

The GC had a two-level structure, G generations each of T steps.
Steps are for aging within a generation, mostly to avoid premature
promotion.

Measurements show that more than 2 steps is almost never worthwhile,
and 1 step is usually worse than 2.  In theory fractional steps are
possible, so the ideal number of steps is somewhere between 1 and 3.
GHC's default has always been 2.

We can implement 2 steps quite straightforwardly by having each block
point to the generation to which objects in that block should be
promoted, so blocks in the nursery point to generation 0, and blocks
in gen 0 point to gen 1, and so on.

This commit removes the explicit step structures, merging generations
with steps, thus simplifying a lot of code.  Performance is
unaffected.  The tunable number of steps is now gone, although it may
be replaced in the future by a way to tune the aging in generation 0.

10 years agofix error message on Windows (fixes rtsflags001)
Simon Marlow [Wed, 2 Dec 2009 14:11:35 +0000 (14:11 +0000)] 
fix error message on Windows (fixes rtsflags001)

10 years agoFix loading of annotations
Roman Leshchinskiy [Fri, 4 Dec 2009 02:42:59 +0000 (02:42 +0000)] 
Fix loading of annotations

The problem was that we collected all annotations we knew about once when the
simplifier started and threaded them through the CoreM monad. If new interface
files were loaded during simplification, their annotations would not be
visible to the simplifier.

Now, we rebuild the annotation list at the start of every simplifier pass that
needs it (which is only SpecConstr at the moment). This ensures that we see
all annotations that have been loaded so far. This is somewhat similar to how
RULES are handled.

10 years agoAdd new ForceSpecConstr annotation
Roman Leshchinskiy [Thu, 3 Dec 2009 06:54:55 +0000 (06:54 +0000)] 
Add new ForceSpecConstr annotation

Annotating a type with {-# ANN type T ForceSpecConstr #-} makes SpecConstr
ignore -fspec-constr-threshold and -fspec-constr-count for recursive functions
that have arguments of type T. Such functions will be specialised regardless
of their size and there is no upper bound on the number of specialisations
that can be generated. This also works if T is embedded in other types such as
Maybe T (but not T -> T).

T should not be a product type because it could be eliminated by the
worker/wrapper transformation. For instance, in

data T = T Int Int

foo :: T -> Int
foo (T m n) = ... foo (T m' n') ...

SpecConstr will never see the T because w/w will get rid of it. I'm still
thinking about whether fixing this is worthwhile.

10 years agoGenerate INLINE pragmas for PA methods
Roman Leshchinskiy [Thu, 3 Dec 2009 03:14:52 +0000 (03:14 +0000)] 
Generate INLINE pragmas for PA methods

10 years agoAdd a GHC layout extension to the alternative layout rule
Ian Lynagh [Thu, 3 Dec 2009 15:57:08 +0000 (15:57 +0000)] 
Add a GHC layout extension to the alternative layout rule

10 years agoFix HPC column numbers, following the column number changes in GHC
Ian Lynagh [Thu, 3 Dec 2009 13:55:20 +0000 (13:55 +0000)] 
Fix HPC column numbers, following the column number changes in GHC

10 years agoWhitespace only
Ian Lynagh [Thu, 3 Dec 2009 13:22:59 +0000 (13:22 +0000)] 
Whitespace only

10 years agoFix column numbers used when highlighting :list output
Ian Lynagh [Thu, 3 Dec 2009 13:03:28 +0000 (13:03 +0000)] 
Fix column numbers used when highlighting :list output

10 years agoadd a missing lock around allocGroup()
Simon Marlow [Thu, 3 Dec 2009 11:02:09 +0000 (11:02 +0000)] 
add a missing lock around allocGroup()

10 years agoremove unused cap->in_gc flag
Simon Marlow [Wed, 2 Dec 2009 15:42:40 +0000 (15:42 +0000)] 
remove unused cap->in_gc flag

10 years agoRefactoring only
Simon Marlow [Wed, 2 Dec 2009 12:38:06 +0000 (12:38 +0000)] 
Refactoring only

10 years agomove sanity checking code from Storage.c to Sanity.c
Simon Marlow [Wed, 2 Dec 2009 12:11:41 +0000 (12:11 +0000)] 
move sanity checking code from Storage.c to Sanity.c

10 years agostg_ap_0_fast: sanity-check only the topmost frame, not the whole stack
Simon Marlow [Wed, 2 Dec 2009 11:51:09 +0000 (11:51 +0000)] 
stg_ap_0_fast: sanity-check only the topmost frame, not the whole stack
Sanity checking was getting too slow in some cases, this returns it to
a constant-factor overhead.

10 years agoFix profiling build
Simon Marlow [Thu, 3 Dec 2009 08:59:30 +0000 (08:59 +0000)] 
Fix profiling build

10 years agoMore work on the simplifier's inlining strategies
simonpj@microsoft.com [Wed, 2 Dec 2009 17:42:56 +0000 (17:42 +0000)] 
More work on the simplifier's inlining strategies

This patch collects a small raft of related changes

* Arrange that during
     (a) rule matching and
     (b) uses of exprIsConApp_maybe
  we "look through" unfoldings only if they are active
  in the phase. Doing this for (a) required a bit of
  extra plumbing in the rule matching code, but I think
  it's worth it.

  One wrinkle is that even if inlining is off (in the 'gentle'
  phase of simplification) during rule matching we want to
  "look through" things with inlinings.
   See SimplUtils.activeUnfInRule.

  This fixes a long-standing bug, where things that were
  supposed to be (say) NOINLINE, could still be poked into
  via exprIsConApp_maybe.

* In the above cases, also check for (non-rule) loop breakers;
  we never look through these.  This fixes a bug that could make
  the simplifier diverge (and did for Roman).
  Test = simplCore/should_compile/dfun-loop

* Try harder not to choose a DFun as a loop breaker. This is
  just a small adjustment in the OccurAnal scoring function

* In the scoring function in OccurAnal, look at the InlineRule
  unfolding (if there is one) not the actual RHS, beause the
  former is what'll be inlined.

* Make the application of any function to dictionary arguments
  CONLIKE.  Thus (f d1 d2) is CONLIKE.
  Encapsulated in CoreUtils.isExpandableApp
  Reason: see Note [Expandable overloadings] in CoreUtils

* Make case expressions seem slightly smaller in CoreUnfold.
  This reverses an unexpected consequences of charging for
  alternatives.

Refactorings
~~~~~~~~~~~~
* Signficantly refactor the data type for Unfolding (again).
  The result is much nicer.

* Add type synonym BasicTypes.CompilerPhase = Int
  and use it

Many of the files touched by this patch are simply knock-on
consequences of these two refactorings.

10 years agoFix Trac #3100: reifyType
simonpj@microsoft.com [Mon, 30 Nov 2009 17:52:04 +0000 (17:52 +0000)] 
Fix Trac #3100: reifyType

A type without any leading foralls may still have constraints
   eg:  ?x::Int => Int -> Int

But reifyType was failing in this case.

Merge to 6.12.

10 years agoFix Trac #3102: pre-matching polytypes
simonpj@microsoft.com [Mon, 30 Nov 2009 17:44:41 +0000 (17:44 +0000)] 
Fix Trac #3102: pre-matching polytypes

When *pre-matching* two types
     forall a. C1 => t1  ~  forall a. C2 => t2
we were matching t1~t2, but totally ignoring C1,C2
That's utterly wrong when pre-matching
       (?p::Int) => String  ~  a
because we emerge with a:=String!

All this is part of the impredicative story, which is about
to go away, but still.

Worth merging this to 6.12

10 years agothreadStackUnderflow: put the new TSO on the mut list if necessary
Simon Marlow [Wed, 2 Dec 2009 14:45:49 +0000 (14:45 +0000)] 
threadStackUnderflow: put the new TSO on the mut list if necessary

10 years agodon't sanity check the whole stack when switching interp<->compiled
Simon Marlow [Wed, 2 Dec 2009 13:41:21 +0000 (13:41 +0000)] 
don't sanity check the whole stack when switching interp<->compiled

10 years agofix to sanity checking for ThreadRelocated TSOs
Simon Marlow [Wed, 2 Dec 2009 13:40:41 +0000 (13:40 +0000)] 
fix to sanity checking for ThreadRelocated TSOs

10 years agosanity check the top stack frame, not the whole stack
Simon Marlow [Wed, 2 Dec 2009 13:40:20 +0000 (13:40 +0000)] 
sanity check the top stack frame, not the whole stack

10 years agoMake allocatePinned use local storage, and other refactorings
Simon Marlow [Tue, 1 Dec 2009 16:03:21 +0000 (16:03 +0000)] 
Make allocatePinned use local storage, and other refactorings

This is a batch of refactoring to remove some of the GC's global
state, as we move towards CPU-local GC.

  - allocateLocal() now allocates large objects into the local
    nursery, rather than taking a global lock and allocating
    then in gen 0 step 0.

  - allocatePinned() was still allocating from global storage and
    taking a lock each time, now it uses local storage.
    (mallocForeignPtrBytes should be faster with -threaded).

  - We had a gen 0 step 0, distinct from the nurseries, which are
    stored in a separate nurseries[] array.  This is slightly strange.
    I removed the g0s0 global that pointed to gen 0 step 0, and
    removed all uses of it.  I think now we don't use gen 0 step 0 at
    all, except possibly when there is only one generation.  Possibly
    more tidying up is needed here.

  - I removed the global allocate() function, and renamed
    allocateLocal() to allocate().

  - the alloc_blocks global is gone.  MAYBE_GC() and
    doYouWantToGC() now check the local nursery only.

10 years agoFree full_prog_argv at exit, closing a memory leak
Simon Marlow [Tue, 1 Dec 2009 12:28:01 +0000 (12:28 +0000)] 
Free full_prog_argv at exit, closing a memory leak

10 years agofree cap->saved_mut_lists too
Simon Marlow [Tue, 1 Dec 2009 11:34:48 +0000 (11:34 +0000)] 
free cap->saved_mut_lists too
fixes some memory leakage at shutdown

10 years agoexitScheduler: move boundTaskExiting call outside #ifdef THREADED_RTS
Simon Marlow [Tue, 1 Dec 2009 11:33:52 +0000 (11:33 +0000)] 
exitScheduler: move boundTaskExiting call outside #ifdef THREADED_RTS
Fixes a little leaked memory at shutdown in non-threaded RTS

10 years agoUse dlltool from the in-tree mingw installation
Ian Lynagh [Tue, 1 Dec 2009 19:05:44 +0000 (19:05 +0000)] 
Use dlltool from the in-tree mingw installation
We only use dlltool on Windows, and this way we don't require that
the user has it installed.

10 years agoFix Commentary link in the HACKING file; trac #3706
Ian Lynagh [Tue, 1 Dec 2009 15:01:49 +0000 (15:01 +0000)] 
Fix Commentary link in the HACKING file; trac #3706

10 years agoAdd an entry fo the ghci command :run to the user guide
Ian Lynagh [Tue, 1 Dec 2009 17:33:39 +0000 (17:33 +0000)] 
Add an entry fo the ghci command :run to the user guide

10 years agoFix typo in docs
Ian Lynagh [Tue, 1 Dec 2009 17:05:50 +0000 (17:05 +0000)] 
Fix typo in docs

10 years agoDelay expansion of some makefile variables until they are available
Ian Lynagh [Tue, 1 Dec 2009 13:36:09 +0000 (13:36 +0000)] 
Delay expansion of some makefile variables until they are available

10 years agoCall $(SED) rather than sed
Ian Lynagh [Tue, 1 Dec 2009 13:11:23 +0000 (13:11 +0000)] 
Call $(SED) rather than sed

10 years agoLook for sed as gsed first
Ian Lynagh [Tue, 1 Dec 2009 13:07:41 +0000 (13:07 +0000)] 
Look for sed as gsed first
Solaris's sed apparently doesn't understand [:space:]

10 years agoAvoid running empty for loops; fixes trac #3683
Ian Lynagh [Tue, 1 Dec 2009 12:59:27 +0000 (12:59 +0000)] 
Avoid running empty for loops; fixes trac #3683
Solaris's sh gives
    /bin/sh: syntax error at line 1: `;' unexpected
when faced with something like
    for x in ; do ...; done
Patch from Christian Maeder.

10 years agoFix PS file generation
Simon Marlow [Tue, 1 Dec 2009 15:42:54 +0000 (15:42 +0000)] 
Fix PS file generation
(the image doesn't work, but at least db2latex doesn't fall over)

10 years agoImplement a new heap-tuning option: -H
Simon Marlow [Mon, 30 Nov 2009 15:18:36 +0000 (15:18 +0000)] 
Implement a new heap-tuning option: -H

-H alone causes the RTS to use a larger nursery, but without exceeding
the amount of memory that the application is already using.  It trades
off GC time against locality: the default setting is to use a
fixed-size 512k nursery, but this is sometimes worse than using a very
large nursery despite the worse locality.

Not all programs get faster, but some programs that use large heaps do
much better with -H.  e.g. this helps a lot with #3061 (binary-trees),
though not as much as specifying -H<large>.  Typically using -H<large>
is better than plain -H, because the runtime doesn't know ahead of
time how much memory you want to use.

Should -H be on by default?  I'm not sure, it makes some programs go
slower, but others go faster.

10 years agoStore a destination step in the block descriptor
Simon Marlow [Sun, 29 Nov 2009 16:42:51 +0000 (16:42 +0000)] 
Store a destination step in the block descriptor
At the moment, this just saves a memory reference in the GC inner loop
(worth a percent or two of GC time).  Later, it will hopefully let me
experiment with partial steps, and simplifying the generation/step
infrastructure.

10 years agoFix the prof_scc.png image in the profiling section (#3694)
Simon Marlow [Mon, 30 Nov 2009 13:27:03 +0000 (13:27 +0000)] 
Fix the prof_scc.png image in the profiling section (#3694)

10 years agodocument 'recache' command in the help output (#3684)
Simon Marlow [Mon, 30 Nov 2009 12:20:40 +0000 (12:20 +0000)] 
document 'recache' command in the help output (#3684)

10 years agoCheck whether the main function is actually exported (#414)
Simon Marlow [Mon, 30 Nov 2009 11:23:27 +0000 (11:23 +0000)] 
Check whether the main function is actually exported (#414)

10 years agoAvoid using non-standard GNU tar option --force-local
Simon Marlow [Mon, 30 Nov 2009 11:26:05 +0000 (11:26 +0000)] 
Avoid using non-standard GNU tar option --force-local

10 years agoReorder ALL_RTS_LIBS
Matthias Kilian [Sun, 15 Nov 2009 17:54:05 +0000 (17:54 +0000)] 
Reorder ALL_RTS_LIBS

ALL_RTS_LIBS is (ab)used for linking ghc when BootingFromHc=Yes,
which needs libHSrtsmain.a before libHSrts.a.

10 years agoUpdate dependencies
Ian Lynagh [Sun, 29 Nov 2009 16:55:34 +0000 (16:55 +0000)] 
Update dependencies

10 years agoFollow Cabal changes
Ian Lynagh [Sun, 29 Nov 2009 16:51:41 +0000 (16:51 +0000)] 
Follow Cabal changes

10 years agoTweak layout to work with alternative layout rule
Ian Lynagh [Sun, 29 Nov 2009 16:30:44 +0000 (16:30 +0000)] 
Tweak layout to work with alternative layout rule

10 years agoTweak the alternative layout rule: {} contains commas
Ian Lynagh [Sun, 29 Nov 2009 15:54:54 +0000 (15:54 +0000)] 
Tweak the alternative layout rule: {} contains commas

10 years agoCorrect the advanceSrcLoc calculation for tabs
Ian Lynagh [Sun, 29 Nov 2009 15:39:33 +0000 (15:39 +0000)] 
Correct the advanceSrcLoc calculation for tabs
It was off-by-one

10 years agoTweak alternative layout rule
Ian Lynagh [Sun, 29 Nov 2009 15:23:23 +0000 (15:23 +0000)] 
Tweak alternative layout rule