ghc.git
5 years agoRejigger flushExec implementation (#8562, #8561)
Austin Seipp [Tue, 26 Nov 2013 09:31:30 +0000 (03:31 -0600)] 
Rejigger flushExec implementation (#8562, #8561)

Instead, just don't do anything on x86/amd64, and on !x86, use either A)
__clear_cache from libgcc, or B) sys_icache_invalidate for OS X (and
iOS.)

Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoghc.mk: one module name per line
Dr. ERDI Gergo [Thu, 21 Nov 2013 05:20:53 +0000 (13:20 +0800)] 
ghc.mk: one module name per line

Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoTypos in comments
Gabor Greif [Tue, 26 Nov 2013 22:18:07 +0000 (23:18 +0100)] 
Typos in comments

5 years agoTypos in comments in TcEvidence
Joachim Breitner [Tue, 26 Nov 2013 16:43:28 +0000 (16:43 +0000)] 
Typos in comments in TcEvidence

5 years agoIn toHsType, filter out kind variables
Joachim Breitner [Mon, 25 Nov 2013 18:16:29 +0000 (18:16 +0000)] 
In toHsType, filter out kind variables

(This fixes #8563)

5 years agoAnother raft of Template Haskell clean-up
Simon Peyton Jones [Mon, 25 Nov 2013 16:58:28 +0000 (16:58 +0000)] 
Another raft of Template Haskell clean-up

The handling of typed and untyped brackets was extremely convoluted,
partly because of the evolutionary history.  I've tidied it all up.

See Note [How brackets and nested splices are handled] in TcSplice
for the full story

Main changes:

 * Untyped brackets: after the renamer, HsRnBracketOut carries
   PendingRnSplices for splices in untyped brackets.  In the
   typechecker, these pending splices are typechecked quite
   straigtforwardly, with no ps_var nonsense.

 * Typed brackets: after the renamer typed brackest still look
   like HsBracket. The type checker does the ps_var thing.

 * In TcRnTypes.ThStage, the Brack constructor, we distinguish
   the renaming from typehecking pending-stuff.  Much more
   perspicuous!

 * The "typed" flag is in HsSpliceE, not in HsSplice, because
   only expressions can be typed.  Patterns, types, declarations
   cannot.

There is further improvement to be done to make the handling of
declaration splices more uniform.

5 years agoUpdate to core-spec documentation.
Richard Eisenberg [Fri, 22 Nov 2013 22:27:32 +0000 (17:27 -0500)] 
Update to core-spec documentation.

This update includes some wibbles to make Co_TyConAppCo clearer,
as well as the introduction of forms for AxiomRuleCo.

5 years agoMention that the user has to import GHC.Exts for Constraint
Joachim Breitner [Sun, 24 Nov 2013 19:38:08 +0000 (19:38 +0000)] 
Mention that the user has to import GHC.Exts for Constraint

(required judging from confusion on #haskell right now.)

5 years agoReplace (State# RealWorld) with Void# where we just want a 0-bit value
Simon Peyton Jones [Fri, 22 Nov 2013 15:23:22 +0000 (15:23 +0000)] 
Replace (State# RealWorld) with Void# where we just want a 0-bit value

We were re-using the super-magical "state token" type (which has
VoidRep and is zero bits wide) for situations in which we simply want
to lambda-abstract over a zero-bit argument. For example, join points:

   case (case x of { True -> e1; False -> e2 }) of
      Red  -> f1
      Blue -> True

==>

  let $j1 = \voidArg::Void# -> f1
  in
  case x of
    True -> case e1 of
              Red -> $j1 void
              Blue -> True
    False -> case e2 of
              Red -> $j1 void
              Blue -> True

This patch introduces

   * The new primitive type GHC.Prim.Void#, with PrimRep = VoidRep

   * A new global Id GHC.Prim.voidPrimId :: Void#.
     This has no binding because the code generator drops it,
     but is used as an argument (eg in the call of $j1)

   * A new local Id, MkId.voidArgId, which can be lambda-bound
     when you need to lambda-abstract over it.

and uses them throughout.

Now the State# thing is used only when we need state!

5 years agoMove isVoidRep, isGcPtrRep to TyCon to join primRepSizeW etc
Simon Peyton Jones [Fri, 22 Nov 2013 15:05:39 +0000 (15:05 +0000)] 
Move isVoidRep, isGcPtrRep to TyCon to join primRepSizeW etc

This is just a modest refactoring

5 years agoUntabify and trailing white space
Simon Peyton Jones [Fri, 22 Nov 2013 15:04:19 +0000 (15:04 +0000)] 
Untabify and trailing white space

5 years agoAdd a missing case to Lint's understanding of empty cases
Simon Peyton Jones [Fri, 22 Nov 2013 15:03:15 +0000 (15:03 +0000)] 
Add a missing case to Lint's understanding of empty cases

   case x:Int# of {}

is OK

5 years agoUse bindLocalNamesFV in rn_inst_info
Joachim Breitner [Fri, 22 Nov 2013 13:40:34 +0000 (13:40 +0000)] 
Use bindLocalNamesFV in rn_inst_info

5 years agoUse newTyConInstRhs in coerce’d GND
Joachim Breitner [Fri, 22 Nov 2013 11:16:55 +0000 (11:16 +0000)] 
Use newTyConInstRhs in coerce’d GND

5 years agoImplement GeneralizedNewtypeDeriving in terms of `coerce`.
Richard Eisenberg [Mon, 11 Nov 2013 18:40:44 +0000 (13:40 -0500)] 
Implement GeneralizedNewtypeDeriving in terms of `coerce`.

5 years agoExtend Coercible to newtype instances
Joachim Breitner [Fri, 22 Nov 2013 10:15:01 +0000 (10:15 +0000)] 
Extend Coercible to newtype instances

This fixes: #8548

5 years agoPrevent recursive Coercible dictionaries
Joachim Breitner [Wed, 20 Nov 2013 14:09:08 +0000 (14:09 +0000)] 
Prevent recursive Coercible dictionaries

5 years agoAdd ctLoc = ctev_loc . cc_ev
Joachim Breitner [Fri, 22 Nov 2013 08:38:10 +0000 (08:38 +0000)] 
Add ctLoc = ctev_loc . cc_ev

5 years agoLarge refactor: Move CtLoc field from Ct to CtEvidence
Joachim Breitner [Thu, 21 Nov 2013 16:40:42 +0000 (16:40 +0000)] 
Large refactor: Move CtLoc field from Ct to CtEvidence

5 years agoAdd -ftype-function-stack to set type function stack depth
Joachim Breitner [Wed, 20 Nov 2013 10:24:52 +0000 (10:24 +0000)] 
Add -ftype-function-stack to set type function stack depth

5 years agoSeparate SubGoalDepthCounters (constraints and typ fun applications)
Joachim Breitner [Wed, 20 Nov 2013 10:04:15 +0000 (10:04 +0000)] 
Separate SubGoalDepthCounters (constraints and typ fun applications)

5 years agoMake SubGoalDepth a type of its own
Joachim Breitner [Wed, 20 Nov 2013 09:24:27 +0000 (09:24 +0000)] 
Make SubGoalDepth a type of its own

In preparation of counting type function applications and constraint
resolving separately.

5 years agoWibble to RnSplice (really belongs with b7f35733)
Simon Peyton Jones [Fri, 22 Nov 2013 09:58:42 +0000 (09:58 +0000)] 
Wibble to RnSplice (really belongs with b7f35733)

5 years agoRefactor TcSplice.tcBracket a bit
Simon Peyton Jones [Fri, 22 Nov 2013 09:41:02 +0000 (09:41 +0000)] 
Refactor TcSplice.tcBracket a bit

The way that untyped brackets are typechecked is still grotesquely
indirect, but I'll sort that out in a subsequent patch

5 years agoClarify what is in ic_tythings, and refactor TcRnDriver.setInteractiveContext
Simon Peyton Jones [Fri, 22 Nov 2013 09:40:10 +0000 (09:40 +0000)] 
Clarify what is in ic_tythings, and refactor TcRnDriver.setInteractiveContext

Previously there was a ton of cruft to do wtih "visible ids" in
setInteractiveContext, but I made it all a lot simpler by providing
a way to add to the typecheckers list of "global type variables",
via TcEnv.tcExtendGlobalTyVars.  This is much nicer.

5 years agoA raft of changes driven by Trac #8540
Simon Peyton Jones [Fri, 22 Nov 2013 09:24:54 +0000 (09:24 +0000)] 
A raft of changes driven by Trac #8540

The root cause of #8450 is that the new Template Haskell story, with
the renamer doing more of the work of Template Haskell, wasn't dealing
correctly with the keepAlive problem.  Consider
    g = ..blah...
    f = [| g |]
Then f's RHS refers to g's name but not to g, so g was being discarded
as dead code.

Fixing this sucked me into a deep swamp of understanding how all the moving
parts of hte new Template Haskell fit together, leading to a large collection
of related changes and better documentation.  Specifically:

* Instead of putting the TH level of a binder in the LocalRdrEnv, there
  is now a separate field
      tcl_th_bndrs :: NameEnv (TopLevelFlag, ThLevel)
  in the TcLclEnv, which records for each binder
     a) whether it is syntactically a top-level binder or not
     b) its TH level
  This deals uniformly with top-level and non-top-level binders, which was
  previously dealt with via greviously-delicate meddling with Internal and
  External Names.  Much better.

* As a result I could remove the tct_level field of ATcId.

* There are consequential changes in TcEnv too, which must also extend the
  level bindings.  Again, more clarity.

  I renamed TcEnv.tcExtendTcTyThingEnv to tcExtendKindEnv2, since it's only used
  during kind inference, for (AThing kind) and APromotionErr; and that is
  relevant to whether we want to extend the tcl_th_bndrs field (no).

* I de-crufted the code in RnEnv.extendGlobalRdrEnv, by getting rid of the
  qual_gre code which said "Seems like 5 times as much work as it deserves!".
  Instead, RdrName.pickGREs makes the Internal names shadow External ones.

* I moved the checkThLocalName cross-stage test to finishHsVar; previously
  we weren't doing the test at all in the OpApp case!

* Quite a few changes (shortening the code) in the cross-stage checking code
  in TcExpr and RnSplice, notably to move the keepAlive call to the renamer

One leftover piece:

* In TcEnv I removed tcExtendGhciEnv and refactored
  tcExtendGlobalTyVars; this is really related to the next commit, but
  it was too hard to disentangle.

5 years agoRefactor traceRunStatus/handleRunStatus
Simon Peyton Jones [Fri, 22 Nov 2013 08:30:41 +0000 (08:30 +0000)] 
Refactor traceRunStatus/handleRunStatus

No change in behaviour, but I combined these two functions, and I think
the result is a good deal clearer

5 years agoImprove pretty-printing of pending splices
Simon Peyton Jones [Fri, 22 Nov 2013 07:54:18 +0000 (07:54 +0000)] 
Improve pretty-printing of pending splices

5 years agoFix type-equality in the type checker (fixes Trac #8553)
Simon Peyton Jones [Fri, 22 Nov 2013 15:48:02 +0000 (15:48 +0000)] 
Fix type-equality in the type checker (fixes Trac #8553)

For horrible reasons (Note [Comparison with OpenTypeKind] in Type), the
function Type.eqType currently equates OOpenKind with *.  This may or may
not be a good idea (it's certainly a revolting one) but it DOES NOT WORK
in the type checker, which *does* need to distinguish OpenKind and *.

Rather than solve the underlying problem (I have some ideas) I just
introduced a new, and very short, simple, straightforward function
TcType.tcEqType to do the job.

5 years agoPrint the correct name when complaining about SPECIALISE pragmas
Simon Peyton Jones [Fri, 22 Nov 2013 15:30:30 +0000 (15:30 +0000)] 
Print the correct name when complaining about SPECIALISE pragmas

Fixes Trac #8537

5 years agoAdd suggestion of -XNegativeLiterals
Simon Peyton Jones [Fri, 22 Nov 2013 10:32:24 +0000 (10:32 +0000)] 
Add suggestion of -XNegativeLiterals

Based on a draft from Krzysztof Gogolewski.
Fixes Trac #8542

5 years agoBetter constraint-solver tracing
Simon Peyton Jones [Thu, 21 Nov 2013 10:28:56 +0000 (10:28 +0000)] 
Better constraint-solver tracing

5 years agoAlways re-summarise modules when -fforce-recomp is set
Patrick Palka [Thu, 14 Nov 2013 00:08:24 +0000 (19:08 -0500)] 
Always re-summarise modules when -fforce-recomp is set

Fixes #8526

5 years agoUntabify buffer.
Austin Seipp [Fri, 22 Nov 2013 14:20:42 +0000 (08:20 -0600)] 
Untabify buffer.

Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoExtend getPhysicalMemorySize to iOS (#8533)
Austin Seipp [Thu, 21 Nov 2013 22:48:24 +0000 (16:48 -0600)] 
Extend getPhysicalMemorySize to iOS (#8533)

Authored-by: Authored-by: Luke Iannini <lukexi@me.com>
Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoTemporarily lower unfolding threshold on Windows
Austin Seipp [Thu, 21 Nov 2013 22:39:41 +0000 (16:39 -0600)] 
Temporarily lower unfolding threshold on Windows

This is a very temporary, very unsatisfactory hack to fix #5987
(for now.)

The included comments essentially say it all: we lower the unfolding
threshold to minimize some amount of exported symbols from the GHC
stage2 DLL. I unfortunately had to lower it quite substantially for the
dynamic stage2 build to pass.

As of this writing, the DLL split between ghc.dll and ghc-0.dll is
something like 26,000 vs 63,000 exported symbols, respectively. So we're
still quite in danger of tripping it, but I think we will be OK at this
exact moment.

Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoComment on StgArrWords vs StgArrBytes
Arash Rouhani [Thu, 21 Nov 2013 13:17:45 +0000 (14:17 +0100)] 
Comment on StgArrWords vs StgArrBytes

See #8552

Signed-off-by: Arash Rouhani <rarash@student.chalmers.se>
Reviewed-by: Austin Seipp <austin@well-typed.com>
5 years agoFix formatting (fixes #8551)
Arash Rouhani [Wed, 20 Nov 2013 01:40:26 +0000 (02:40 +0100)] 
Fix formatting (fixes #8551)

Signed-off-by: Arash Rouhani <rarash@student.chalmers.se>
Reviewed-by: Austin Seipp <austin@well-typed.com>
5 years agoM-x delete-trailing-whitespace
Austin Seipp [Tue, 12 Nov 2013 22:46:03 +0000 (16:46 -0600)] 
M-x delete-trailing-whitespace

Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoFix make binary-dist on OS X (#8122)
Austin Seipp [Tue, 12 Nov 2013 22:43:50 +0000 (16:43 -0600)] 
Fix make binary-dist on OS X (#8122)

Authored-by: Christiaan Baaj <christiaan.baaij@gmail.com>
Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoGHCi: Properly generate jump code for ARM (#8380)
Austin Seipp [Mon, 11 Nov 2013 16:26:03 +0000 (10:26 -0600)] 
GHCi: Properly generate jump code for ARM (#8380)

This adds code for jumping to given addresses for ARM, written by Ben
Gamari.

However, when allocating new infotables for bytecode (which is where
this jump code occurs), we need to be sure to flush the cache on the
execute pointer returned from allocateExec() - on systems like ARM, the
processor won't reliably read back code or automatically cache flush,
where x86 will.

So we add a new flushExec primitive to call out to GCC's
__builtin___clear_cache primitive, which will properly generate the
correct code (nothing on x86, and a call to libgcc's __clear_cache on
ARM) and make sure we use it after writing the code out.

Authored-by: Ben Gamari <bgamari.foss@gmail.com>
Authored-by: Austin Seipp <austin@well-typed.com>
Signed-off-by: Austin Seipp <austin@well-typed.com>
5 years agoIgnore untracked contents in submodules
Joachim Breitner [Fri, 22 Nov 2013 11:22:15 +0000 (11:22 +0000)] 
Ignore untracked contents in submodules

The GHC build creates files there that are not part of the project’s
.gitignore, and clutter up "git status" in ghc/. With this patch, these
changes are ignored; modifications to existing files in the submodule
repositories are still reported.

5 years agoWhen removing unreachable code, remove unreachable info tables too
Simon Peyton Jones [Fri, 22 Nov 2013 10:12:55 +0000 (10:12 +0000)] 
When removing unreachable code, remove unreachable info tables too

This bug only shows up when you are using proc-point splitting.
What was happening was:
  * We generate a proc-point for the stack check
  * And an info table
  * We eliminate the stack check because it's redundant
  * And the dangling info table caused a panic in
    CmmBuildInfoTables.bundle

5 years agoImprove panic printout
Simon Peyton Jones [Fri, 22 Nov 2013 10:10:13 +0000 (10:10 +0000)] 
Improve panic printout

5 years agoAdd debug dump of the list of Cmm proc points
Simon Peyton Jones [Thu, 21 Nov 2013 22:48:26 +0000 (22:48 +0000)] 
Add debug dump of the list of Cmm proc points

5 years agoDon't complain about rules overlapping functions with no unfolding
Simon Peyton Jones [Thu, 21 Nov 2013 22:47:01 +0000 (22:47 +0000)] 
Don't complain about rules overlapping functions with no unfolding

This showed up when importing a module that was compiled
without -O, so there were no unfoldings in the interface file

5 years agoGrammar in comments
Gabor Greif [Fri, 22 Nov 2013 08:09:45 +0000 (09:09 +0100)] 
Grammar in comments

5 years agoAllow the linker to be used without retaining CAFs unconditionally
Simon Marlow [Thu, 21 Nov 2013 12:27:27 +0000 (12:27 +0000)] 
Allow the linker to be used without retaining CAFs unconditionally

This creates a new C API:

   initLinker_ (int retain_cafs)

The old initLinker() was left as-is for backwards compatibility.  See
documentation in Linker.h.

5 years agoCheckUnload needs to look at revertible_caf_list
Simon Marlow [Thu, 21 Nov 2013 12:25:30 +0000 (12:25 +0000)] 
CheckUnload needs to look at revertible_caf_list

Retained CAFs must keep an object file alive.

5 years agoIn the DEBUG rts, track when CAFs are GC'd
Simon Marlow [Thu, 21 Nov 2013 11:28:13 +0000 (11:28 +0000)] 
In the DEBUG rts, track when CAFs are GC'd

This resurrects some old code and makes it work again.  The idea is
that we want to get an error message if we ever enter a CAF that has
been GC'd, rather than following its indirection which will likely
cause a segfault.  Without this patch, these bugs are hard to track
down in gdb, because the IND_STATIC code overwrites R1 (the pointer to
the CAF) with its indirectee before jumping into bad memory, so we've
lost the address of the CAF that got GC'd.

Some associated refactoring while I was here.

5 years ago80 columns
Simon Marlow [Thu, 21 Nov 2013 09:50:34 +0000 (09:50 +0000)] 
80 columns

5 years agoComment
Simon Marlow [Thu, 21 Nov 2013 09:47:24 +0000 (09:47 +0000)] 
Comment

5 years ago80 columns
Simon Marlow [Tue, 22 Oct 2013 19:49:33 +0000 (20:49 +0100)] 
80 columns

5 years ago80 columns
Simon Marlow [Tue, 22 Oct 2013 19:49:25 +0000 (20:49 +0100)] 
80 columns

5 years agorefactor tick handling a little
Simon Marlow [Thu, 21 Nov 2013 09:59:40 +0000 (09:59 +0000)] 
refactor tick handling a little

5 years agotickishCanSplit should be False for HpcTick
Simon Marlow [Thu, 21 Nov 2013 09:52:24 +0000 (09:52 +0000)] 
tickishCanSplit should be False for HpcTick

(no functional changes I hope)

5 years agomkNoScope: expand the default case
Simon Marlow [Thu, 21 Nov 2013 09:51:33 +0000 (09:51 +0000)] 
mkNoScope: expand the default case

5 years agoRename mkNoTick to mkNoCount
Simon Marlow [Thu, 21 Nov 2013 09:45:57 +0000 (09:45 +0000)] 
Rename mkNoTick to mkNoCount

5 years agoFix branch name check regex in sync-all
Joachim Breitner [Thu, 21 Nov 2013 13:14:56 +0000 (13:14 +0000)] 
Fix branch name check regex in sync-all

6 years agoExplain higher-kinded Coerctions in Note [Coercible Instances]
Joachim Breitner [Tue, 19 Nov 2013 17:11:08 +0000 (17:11 +0000)] 
Explain higher-kinded Coerctions in Note [Coercible Instances]

(although there is not really a lot to explain, it seems.)

6 years agoCoercible: Do not try to unwrap undersaturated newtypes
Joachim Breitner [Tue, 19 Nov 2013 12:09:40 +0000 (12:09 +0000)] 
Coercible: Do not try to unwrap undersaturated newtypes

otherwise we get a panic.

6 years agoMake Coercible higher-kinded
Joachim Breitner [Tue, 19 Nov 2013 11:46:25 +0000 (11:46 +0000)] 
Make Coercible higher-kinded

This implements #8541. The changes are fully straight forward and work
nicely for the examples from the ticket; this is mostly due to the
existing code not checking for saturation and kindness.

6 years agoUpdate `primitive` to upstream's current HEAD
Herbert Valerio Riedel [Tue, 19 Nov 2013 21:34:14 +0000 (22:34 +0100)] 
Update `primitive` to upstream's current HEAD

This includes a fix to silence a GCC warning which causes validate failures
on OSX (see haskell/primitive#4 for more details)

6 years agoTypos in [CPR for sum types]
Joachim Breitner [Tue, 19 Nov 2013 08:14:54 +0000 (08:14 +0000)] 
Typos in [CPR for sum types]

6 years agoImprove the 'deriving' code for polykinded data types
Simon Peyton Jones [Mon, 18 Nov 2013 18:11:43 +0000 (18:11 +0000)] 
Improve the 'deriving' code for polykinded data types

Fixes Trac #8534.  See Note [Match kinds in deriving] in TcDeriv.

6 years agoFix typo in a836b6, 'Improve orientation'
Simon Peyton Jones [Mon, 18 Nov 2013 18:09:28 +0000 (18:09 +0000)] 
Fix typo in a836b6, 'Improve orientation'

Just a straightforward error, now fixed.

6 years agoGeneric1 cannot yet be derived for datatypes with tuples with a parameter not in...
Jose Pedro Magalhaes [Mon, 18 Nov 2013 14:26:25 +0000 (14:26 +0000)] 
Generic1 cannot yet be derived for datatypes with tuples with a parameter not in the last position

6 years agofixing canDoGenerics1 (fixes #8468) (fixes #8479)
Nicolas Frisby [Sat, 9 Nov 2013 22:08:46 +0000 (16:08 -0600)] 
fixing canDoGenerics1 (fixes #8468) (fixes #8479)

Signed-off-by: Jose Pedro Magalhaes <jpm@cs.ox.ac.uk>
6 years agoTypo
Krzysztof Gogolewski [Mon, 18 Nov 2013 12:26:44 +0000 (13:26 +0100)] 
Typo

6 years agoMinor change to error message wording
Krzysztof Gogolewski [Sun, 17 Nov 2013 12:56:24 +0000 (13:56 +0100)] 
Minor change to error message wording

One flag is deprecated, other removed

6 years agoTypo: s/LlVM/LlVM/
Joachim Breitner [Sun, 17 Nov 2013 10:13:42 +0000 (10:13 +0000)] 
Typo: s/LlVM/LlVM/

6 years agoInclude funTyCon in oprhNamesOfType (fixes Trac #8535)
Simon Peyton Jones [Fri, 15 Nov 2013 18:49:07 +0000 (18:49 +0000)] 
Include funTyCon in oprhNamesOfType (fixes Trac #8535)

Thanks to parcs for identifying both the bug and the right solution.

6 years agoFix canIrredPred again
Simon Peyton Jones [Fri, 15 Nov 2013 18:47:38 +0000 (18:47 +0000)] 
Fix canIrredPred again

This follows up the earlier patch to Trac #6068, which I
obviously hadn't validated properly.

6 years agoImprove orientation
Simon Peyton Jones [Fri, 15 Nov 2013 18:46:57 +0000 (18:46 +0000)] 
Improve orientation

I came across some stupid re-orientation, when debugging something else.
For example, we were re-orienting

    t ~ fsk
to
   fsk ~ t
where fsk is a flatten *skolem* and t is a meta type varaible.
The logic was just wrong.

6 years agoFix a subtle bug in kind-mis-matched equalities (Trac #6068)
Simon Peyton Jones [Fri, 15 Nov 2013 11:50:19 +0000 (11:50 +0000)] 
Fix a subtle bug in kind-mis-matched equalities (Trac #6068)

When we have an equality constraint where the LHS and RHS
have ill-matched kinds, it get turned into a CIrredEvCan
because a CTyEqCan/CFunEqCan are guaranteed kind-compatible.

But that in turn led to a bug because in the constraint
    c  =  (a:k1) ~ (b:k2)
the kind variables k1 and k2 don't show up in tyVarsOfType c.
Why not?  Because it looks like
    (~) k1 (a:k1) (b:k2)
Maybe (~) should have two kind arguments?  That seemed
like too big a change for not (we wait for NoKinds), so
this patch fixes the bug for now.

6 years agoImprove error message
Simon Peyton Jones [Fri, 15 Nov 2013 11:25:48 +0000 (11:25 +0000)] 
Improve error message

Accommodating Simon M's suggestion (Trac #4268, comment 17)

6 years agoFix the unlit path in count_lines
Simon Peyton Jones [Fri, 15 Nov 2013 11:24:46 +0000 (11:24 +0000)] 
Fix the unlit path in count_lines

6 years agoSimplify and improve coverage of ":info" instance lookup
Patrick Palka [Thu, 14 Nov 2013 22:40:55 +0000 (17:40 -0500)] 
Simplify and improve coverage of ":info" instance lookup

During instance lookup, we can treat classes and data families like any
other TyCon instead of special-casing them.  This approach, aside from
being simpler, has the benefit of returning extra relevant instances for
classes and data families.  For example, given

class A a
instance B (a :: Constraint)
instance A B

":info B" will now also print "instance A B" where previously it didn't
due to the special casing of class TyCons in lookupInsts.

This improves upon the existing patch for Trac #4175

6 years agoChange the representation and move TcBuiltInSynFamily.
Iavor S. Diatchki [Thu, 14 Nov 2013 18:50:52 +0000 (10:50 -0800)] 
Change the representation and move TcBuiltInSynFamily.

The changes in more detail:

  * `TcBuiltInSynFamily` is now known as `BuiltinSynFamily` and
     lives in `CoAxiom`

  * `sfMatchFam` returns (CoAxiomRule, [Type], Type),
     which is enough to make Coersion or TcCoercion,
     depending on what what we need.

  * The rest of the compiler is updated to reflect these changes,
    most notably we can eliminate the cludge (XXX) in FamInstEnv
    and remove the lhs-boot file.

6 years agoDon translate UserInterrupt into ExitFailure 1, let it propagate
Duncan Coutts [Thu, 14 Nov 2013 16:02:03 +0000 (16:02 +0000)] 
Don translate UserInterrupt into ExitFailure 1, let it propagate

It is important that if a program recieved ^C from the user, and the
program terminates as a result, that it exit with SIGINT so that the
parent process knows that was the case. For example cabal calling ghc
will then be able to tell the difference between it failing and the user
interrupting with ^C and report (or not) appropriately.

So we should just let the UserInterrupt exception propagate to the top
level error handler which will do the right thing.

See http://www.cons.org/cracauer/sigint.html

6 years agoImprove the shutdownHaskellAndSignal and add fast exit
Duncan Coutts [Thu, 14 Nov 2013 15:54:13 +0000 (15:54 +0000)] 
Improve the shutdownHaskellAndSignal and add fast exit

This is the RTS part of a patch to base's topHandler to handle exiting
by a signal.

The intended behaviour is that on Unix, throwing ExitFailure (-sig)
results in the process terminating with that signal. Previously
shutdownHaskellAndSignal was only used for exiting with SIGINT due to
the UserInterrupt exception.

Improve shutdownHaskellAndSignal to do the signal part more carefully.
In particular, it (should) now reliably terminates the process one way
or another. Previusly if the signal was blocked, ignored or handled then
shutdownHaskellAndSignal would actually return!

Also, the topHandler code has two paths a careful shutdown and a "fast
exit" where it does not give finalisers a chance to run. We want to
support that mode also when we want to exit by signal. So rather than
the base code directly calling stg_exit as it did before, we have a
fastExit bool paramater for both shutdownHaskellAnd{Exit,Signal}.

6 years agoFix some cases where we were leaving slop in the heap (#8515, #8298)
Simon Marlow [Thu, 14 Nov 2013 09:13:51 +0000 (09:13 +0000)] 
Fix some cases where we were leaving slop in the heap (#8515, #8298)

6 years agosimplify processNurseryForDead
Simon Marlow [Wed, 13 Nov 2013 14:48:51 +0000 (14:48 +0000)] 
simplify processNurseryForDead

It wasn't actually broken, but it wasn't obviously right either.

6 years agocomments
Simon Marlow [Wed, 13 Nov 2013 14:45:45 +0000 (14:45 +0000)] 
comments

6 years agofix a small memory leak with +RTS -hb
Simon Marlow [Wed, 13 Nov 2013 10:21:47 +0000 (10:21 +0000)] 
fix a small memory leak with +RTS -hb

6 years agoUpdate `Cabal` to 1.18.1.2 (again)
Herbert Valerio Riedel [Thu, 14 Nov 2013 10:17:31 +0000 (11:17 +0100)] 
Update `Cabal` to 1.18.1.2 (again)

Cabal was already updated to 1.18.1.2. last month, but then got reverted
by accident by 06aac68dee100b21dc7d304fa90d9baa423507a0

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
6 years agoFix bug in LLVM code generator
Ben Lippmeier [Wed, 6 Nov 2013 02:05:52 +0000 (13:05 +1100)] 
Fix bug in LLVM code generator

The bitcast operation always needs a type for the source.

6 years agoMake the fields in NameCache strict
Patrick Palka [Sat, 9 Nov 2013 19:23:46 +0000 (14:23 -0500)] 
Make the fields in NameCache strict

We've already been making sure to strictly modify the global name cache
in order to avoid space leaks.  However, that does us little good if the
fields of the name cache are not made strict as well.

6 years agoTurn NameCacheUpdater into a newtype
Patrick Palka [Sat, 9 Nov 2013 19:23:15 +0000 (14:23 -0500)] 
Turn NameCacheUpdater into a newtype

6 years agoRemove unnecessary and deprecated inclusions of Typeable.h
Patrick Palka [Fri, 8 Nov 2013 22:27:50 +0000 (17:27 -0500)] 
Remove unnecessary and deprecated inclusions of Typeable.h

The build system would've complained loudly about these inclusions if it
weren't for #8527.

6 years agoRemove old workaround for containers <= 0.3
Patrick Palka [Fri, 8 Nov 2013 22:15:26 +0000 (17:15 -0500)] 
Remove old workaround for containers <= 0.3

6 years agoMake type-level evaluation work with :kind!
Iavor S. Diatchki [Wed, 13 Nov 2013 00:36:23 +0000 (16:36 -0800)] 
Make type-level evaluation work with :kind!

The main change is to add a case to `reduceTyFamApp_maybe` to evaluate
built-in type constructors (e.g., (+), (*), and friends).

To avoid problems with recursive modules, I moved the definition of
TcBuiltInSynFamily from `FamInst` to `FamInstEnv`.  I am still not sure if
this is the right place.

There is also a wibble that it'd be nice to fix:

when we evaluate a built-in type function, using`sfMatchFam`, we get
a `TcCoercion`.  However, `reduceTyFamApp_maybe` needs a `Corecion`.
I couldn't find a nice way to convert between the two, so I resorted to
a bit of hack (marked with `XXX`).

The hack is that we happen to know that the built-in constructors for
the type-nat functions always return coercions of shape `TcAxiomRuleCo`,
with no assumptions, so it easy to convert `TcCoercion` to `Coercion`
in this one case.  This is enough to make things work, but it is clearly
a cludge.

6 years agoFurther refactoring to the tuple-typechecking patch
Simon Peyton Jones [Tue, 12 Nov 2013 18:11:14 +0000 (18:11 +0000)] 
Further refactoring to the tuple-typechecking patch

6 years agoMake exprType work correctly in the presnce of type bindings (Trac #8522)
Simon Peyton Jones [Tue, 12 Nov 2013 15:10:01 +0000 (15:10 +0000)] 
Make exprType work correctly in the presnce of type bindings (Trac #8522)

6 years agoImprove typechecking of tuples (Trac #8514)
Simon Peyton Jones [Tue, 12 Nov 2013 15:09:15 +0000 (15:09 +0000)] 
Improve typechecking of tuples (Trac #8514)

6 years agoImprove eta expansion (again)
Simon Peyton Jones [Tue, 12 Nov 2013 13:12:16 +0000 (13:12 +0000)] 
Improve eta expansion (again)

The presenting issue was that we were never eta-expanding

    f (\x -> case x of (a,b) -> \s -> blah)

and that meant we were allocating two lambdas instead of one.
See Note [Eta expanding lambdas] in SimplUtils.

However I didn't want to eta expand the lambda, and then try all over
again for tryEtaExpandRhs.  Yet the latter is important in the context
of a let-binding it can do simple arity analysis.  So I ended up
refactoring CallCtxt so that it tells when we are on the RHS of a let.

I also moved findRhsArity from SimplUtils to CoreArity.

Performance increases nicely. Here are the ones where allocation improved
by more than 0.5%. Notice the nice decrease in binary size too.

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
           ansi          -2.3%     -0.9%      0.00      0.00     +0.0%
           bspt          -2.1%     -9.7%      0.01      0.01    -33.3%
          fasta          -1.8%    -11.7%     -3.4%     -3.6%     +0.0%
            fft          -1.9%     -1.3%      0.06      0.06    +11.1%
reverse-complem          -1.9%    -18.1%     -1.9%     -2.8%     +0.0%
         sphere          -1.8%     -4.5%      0.09      0.09     +0.0%
      transform          -1.8%     -2.3%     -4.6%     -3.1%     +0.0%
--------------------------------------------------------------------------------
            Min          -3.0%    -18.1%    -13.9%    -14.6%    -35.7%
            Max          -1.3%     +0.0%     +7.7%     +7.7%    +50.0%
 Geometric Mean          -1.9%     -0.6%     -2.1%     -2.1%     -0.2%

6 years agoFix egregious omission in CSE (Trac #5996)
Simon Peyton Jones [Tue, 12 Nov 2013 12:59:15 +0000 (12:59 +0000)] 
Fix egregious omission in CSE (Trac #5996)

This patch fixes a bad omission in CSE, thanks to 'michaelt' for spotting
it, and correctly identifying the fix (in cseRhs).  The trouble was with
   x1 = C a b
   x2 = C x1 b
   y1 = C a b
   y2 = C y1 b
we were not commoning up y2=x2, because we failed to substitute y1:=x1,
so y2's RHS looked different to x2's

I also refactoring, so taht the cs_map in a CSEnv map is
       cs_map    :: CoreMap (OutExpr, Id)
instead of
       cs_map    :: CoreMap (OutExpr, OutExpr)
Much nicer!

This doesn't make much difference to allocation, but it gives a surprisingly
big benefit to binary size.

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
           ansi          -1.7%     -0.8%      0.00      0.00     +0.0%
           bspt          -1.6%     -1.5%      0.01      0.01     +0.0%
      cacheprof          -1.8%     -0.2%     +1.6%     +1.9%     +2.7%
            fft          -1.4%     -1.3%      0.06      0.06    +11.1%
            ida          -1.4%     -1.0%      0.12      0.12     +0.0%
           rfib          -1.4%     -0.1%      0.03      0.03     +0.0%
            scs          -1.6%     -0.1%     +1.5%     +1.5%     +0.0%
  spectral-norm          -1.3%     -0.1%     -0.2%     -0.2%     +0.0%
            tak          -1.4%     -0.1%      0.02      0.02     +0.0%
        veritas          -1.4%     -0.1%      0.00      0.00     +0.0%
--------------------------------------------------------------------------------
            Min          -2.5%     -1.5%    -11.8%    -11.8%     -8.0%
            Max          -1.0%     +0.0%     +2.7%     +2.5%    +11.1%
 Geometric Mean          -1.3%     -0.1%     -2.6%     -2.6%     +0.0%

6 years agoWarn if you use ANN annotations with a stage-1 compiler (Trac #4268)
Simon Peyton Jones [Mon, 11 Nov 2013 08:52:51 +0000 (08:52 +0000)] 
Warn if you use ANN annotations with a stage-1 compiler (Trac #4268)

This makes us give a civilised warning when we hit an
  {-# ANN f foo #-}
pragma in a stage-1 compiler.

We decided that, since it's a pragma, it does not need a language
extension flag to enable it.

6 years agoMake -XTemplateHaskell an error in a stage-1 compiler (except with -M)
Simon Peyton Jones [Mon, 11 Nov 2013 08:51:05 +0000 (08:51 +0000)] 
Make -XTemplateHaskell an error in a stage-1 compiler (except with -M)

Fixes Trac #8519

6 years agoTypos in note
Gabor Greif [Tue, 12 Nov 2013 00:50:05 +0000 (01:50 +0100)] 
Typos in note