ghc-hetmet.git
15 years agoTrim redundant import
simonpj@microsoft.com [Fri, 5 Dec 2008 10:10:06 +0000 (10:10 +0000)]
Trim redundant import

15 years agoMake CoreTidy retain deadness info (better -ddump-simpl)
simonpj@microsoft.com [Fri, 5 Dec 2008 10:05:18 +0000 (10:05 +0000)]
Make CoreTidy retain deadness info (better -ddump-simpl)

GHC now retains more robust information about dead variables; but
CoreTidy was throwing it away.  This patch makes CoreTidy retain it,
which gives better output for -ddump-simpl.

New opportunity: shrink interface files by using wildcards for dead variables.

15 years agoRemove INLINE pragmas on recursive functions
simonpj@microsoft.com [Fri, 5 Dec 2008 10:03:53 +0000 (10:03 +0000)]
Remove INLINE pragmas on recursive functions

INLINE pragmas on recursive functions are ignored; and this
is checked in my upcoming patch for inlinings.

15 years agoComments only (on Activation)
simonpj@microsoft.com [Fri, 5 Dec 2008 10:01:39 +0000 (10:01 +0000)]
Comments only (on Activation)

15 years agoWe need to tell cabal-bin which version of Cabal to use
Ian Lynagh [Wed, 3 Dec 2008 12:32:08 +0000 (12:32 +0000)]
We need to tell cabal-bin which version of Cabal to use
Otherwise, if the bootstrapping compiler has a newer version, we get
a mismatch between the version used to compile ghc-prim's Setup.hs and
the version that installPackage uses.

15 years agoDocument 'loadModule'.
Thomas Schilling [Tue, 2 Dec 2008 15:48:00 +0000 (15:48 +0000)]
Document 'loadModule'.

15 years agoAdd 'needsTemplateHaskell' utility function and document why one might
Thomas Schilling [Tue, 2 Dec 2008 15:23:58 +0000 (15:23 +0000)]
Add 'needsTemplateHaskell' utility function and document why one might
want to use it.

15 years agoDocumentation only.
Thomas Schilling [Tue, 2 Dec 2008 15:01:58 +0000 (15:01 +0000)]
Documentation only.

15 years agoExport 'succeeded' and 'failed' helper functions.
Thomas Schilling [Tue, 2 Dec 2008 14:44:51 +0000 (14:44 +0000)]
Export 'succeeded' and 'failed' helper functions.

15 years agoPut full ImportDecls in ModSummary instead of just ModuleNames
Simon Marlow [Tue, 2 Dec 2008 13:37:36 +0000 (13:37 +0000)]
Put full ImportDecls in ModSummary instead of just ModuleNames
... and use it to make ghc -M generate correct cross-package
dependencies when using package-qualified imports (needed for the new
build system).  Since we're already parsing the ImportDecl from the
source file, there seems no good reason not to keep it in the
ModSummary, it might be useful for other things too.

15 years agoghc -M: need to add a dep on Prelude unless -fno-implicit-prelude is on
Simon Marlow [Fri, 28 Nov 2008 16:57:07 +0000 (16:57 +0000)]
ghc -M: need to add a dep on Prelude unless -fno-implicit-prelude is on

15 years agomake -include-pkg-deps work (not sure when this got lost)
Simon Marlow [Fri, 28 Nov 2008 13:57:46 +0000 (13:57 +0000)]
make -include-pkg-deps work (not sure when this got lost)

15 years agoFix more problems caused by padding in the Capability structure
Simon Marlow [Tue, 2 Dec 2008 12:07:35 +0000 (12:07 +0000)]
Fix more problems caused by padding in the Capability structure
Fixes crashes on Windows and Sparc

15 years agoadd missing case to Ord GlobalReg (EagerBlackhole == EagerBlackhole)
Simon Marlow [Fri, 28 Nov 2008 13:01:06 +0000 (13:01 +0000)]
add missing case to Ord GlobalReg (EagerBlackhole == EagerBlackhole)

15 years agoBetter error message for fundep conflict
simonpj@microsoft.com [Mon, 1 Dec 2008 16:28:45 +0000 (16:28 +0000)]
Better error message for fundep conflict

15 years agoFix typo in quasi-quote documentation's sample.
shelarcy [Sat, 29 Nov 2008 02:43:44 +0000 (02:43 +0000)]
Fix typo in quasi-quote documentation's sample.

15 years agoRemove the v_Split_info global variable and use a field of dflags instead
Ian Lynagh [Sun, 30 Nov 2008 15:24:03 +0000 (15:24 +0000)]
Remove the v_Split_info global variable and use a field of dflags instead

15 years agoDocument the --machine-readable RTS flag
Ian Lynagh [Sun, 30 Nov 2008 15:23:11 +0000 (15:23 +0000)]
Document the --machine-readable RTS flag

15 years agoLet 'loadModule' generate proper code depending on the 'hscTarget'.
Thomas Schilling [Fri, 28 Nov 2008 16:44:12 +0000 (16:44 +0000)]
Let 'loadModule' generate proper code depending on the 'hscTarget'.

With this change it should be possible to perform something similar to
'load' by traversing the module graph in dependency order and calling
'{parse,typecheck,load}Module' on each.  Of course, if you want smart
recompilation checking you should still use 'load'.

15 years agoExpose a separate 'hscBackend' phase for 'HsCompiler' and change
Thomas Schilling [Fri, 28 Nov 2008 16:37:46 +0000 (16:37 +0000)]
Expose a separate 'hscBackend' phase for 'HsCompiler' and change
parameter to 'InteractiveStatus' to a 'Maybe'.

15 years agoWhoops, *don't* reset the complete session in 'withLocalCallbacks'.
Thomas Schilling [Fri, 28 Nov 2008 15:07:27 +0000 (15:07 +0000)]
Whoops, *don't* reset the complete session in 'withLocalCallbacks'.

15 years agoUse a record instead of a typeclass for 'HsCompiler'. This is mostly
Thomas Schilling [Fri, 28 Nov 2008 12:19:47 +0000 (12:19 +0000)]
Use a record instead of a typeclass for 'HsCompiler'.  This is mostly
equivalent to a typeclass implementation that uses a functional
dependency from the target mode to the result type.

15 years agoRemove dead code
Ian Lynagh [Fri, 28 Nov 2008 19:38:31 +0000 (19:38 +0000)]
Remove dead code

15 years agoUpdate docs not to talk about deprecated -optdep-* flags; fixes trac #2773
Ian Lynagh [Fri, 28 Nov 2008 19:36:33 +0000 (19:36 +0000)]
Update docs not to talk about deprecated -optdep-* flags; fixes trac #2773

15 years agoUse relative URLs in the GHC API haddock docs; fixes #2755
Ian Lynagh [Fri, 28 Nov 2008 18:45:11 +0000 (18:45 +0000)]
Use relative URLs in the GHC API haddock docs; fixes #2755

15 years agoTeach runghc about --help; fixes trac #2757
Ian Lynagh [Fri, 28 Nov 2008 19:17:06 +0000 (19:17 +0000)]
Teach runghc about --help; fixes trac #2757

15 years agoUse a per-session data structure for callbacks. Make 'WarnErrLogger'
Thomas Schilling [Fri, 28 Nov 2008 10:36:28 +0000 (10:36 +0000)]
Use a per-session data structure for callbacks.  Make 'WarnErrLogger'
part of it.

Part of the GHC API essentially represents a compilation framework.
The difference of a *framework* as opposed to a *library* is that the
overall structure of the functionality is pre-defined but certain
details can be customised via callbacks.  (Also known as the Hollywood
Principle: "Don't call us, we'll call you.")

This patch introduces a per-session data structure that contains all
the callbacks instead of adding lots of small function arguments
whenever we want to give the user more control over certain parts of
the API.  This should also help with future changes: Adding a new
callback doesn't break old code since code that doesn't know about the
new callback will use the (hopefully sane) default implementation.

Overall, however, we should try and keep the number of callbacks small
and well-defined (and provide useful defaults) and use simple library
routines for the rest.

15 years agoImprove error message for #2739 (but no fix).
Thomas Schilling [Thu, 27 Nov 2008 13:57:25 +0000 (13:57 +0000)]
Improve error message for #2739 (but no fix).

This patch changes 'loadModule' to define a fake linkable.  The
previous implementation of providing no linkable at all violated a
pre-condition in the ByteCode linker.  This doesn't fix #2739, but it
improves the error message a bit.

15 years agoRemove the packing I added recently to the Capability structure
Simon Marlow [Fri, 28 Nov 2008 10:50:46 +0000 (10:50 +0000)]
Remove the packing I added recently to the Capability structure
The problem is that the packing caused some unaligned loads, which
lead to bus errors on Sparc (and reduced performance elsewhere,
presumably).

15 years agodon't emit CmmComments for now
Simon Marlow [Thu, 27 Nov 2008 09:01:45 +0000 (09:01 +0000)]
don't emit CmmComments for now
  - if the string contains */, we need to fix it (demonstrated by
    building Cabal with -fvia-C)
  - the strings can get quite large, so we probably only want to
    inject comments when some debugging option is on.

15 years agoCollect instead of print warnings in 'warnUnnecessarySourceImports'.
Thomas Schilling [Thu, 27 Nov 2008 10:25:34 +0000 (10:25 +0000)]
Collect instead of print warnings in 'warnUnnecessarySourceImports'.

15 years agoForce recompilation of BCOs when they were compiled in HscNothing mode.
Thomas Schilling [Wed, 26 Nov 2008 18:34:02 +0000 (18:34 +0000)]
Force recompilation of BCOs when they were compiled in HscNothing mode.

Previously, loading a set of modules in HscNothing mode and then
switching to HscInterpreted could lead to crashes since modules
compiled with HscNothing were thought to be valid bytecode objects.

This patch forces recompilation in these cases, hence switching between
HscNothing and HscInterpreted should be safe now.

15 years agoDocumentation only: Add module description for HscMain.
Thomas Schilling [Wed, 26 Nov 2008 13:43:44 +0000 (13:43 +0000)]
Documentation only: Add module description for HscMain.

15 years agoInclude GHCi files in ctags/etags.
Thomas Schilling [Wed, 26 Nov 2008 12:28:01 +0000 (12:28 +0000)]
Include GHCi files in ctags/etags.

15 years agodrop some debugging traces and use only one flag for new codegen
dias@eecs.harvard.edu [Wed, 26 Nov 2008 18:08:08 +0000 (18:08 +0000)]
drop some debugging traces and use only one flag for new codegen

15 years agoone more missing patch from new codegen path
dias@eecs.harvard.edu [Wed, 26 Nov 2008 16:57:42 +0000 (16:57 +0000)]
one more missing patch from new codegen path

15 years agoFix Trac #2817 (TH syntax -> HsSyn conversion)
simonpj@microsoft.com [Wed, 26 Nov 2008 15:40:22 +0000 (15:40 +0000)]
Fix Trac #2817 (TH syntax -> HsSyn conversion)

15 years agoFix Trac #2756: CorePrep strictness bug
simonpj@microsoft.com [Wed, 26 Nov 2008 14:34:48 +0000 (14:34 +0000)]
Fix Trac #2756: CorePrep strictness bug

15 years agoFormat output for :t more nicely
simonpj@microsoft.com [Wed, 26 Nov 2008 13:48:14 +0000 (13:48 +0000)]
Format output for :t more nicely

15 years agoFix Trac #2766: printing operator type variables
simonpj@microsoft.com [Wed, 26 Nov 2008 13:22:02 +0000 (13:22 +0000)]
Fix Trac #2766: printing operator type variables

15 years agoFix build following codegen patch
simonpj@microsoft.com [Wed, 26 Nov 2008 12:55:26 +0000 (12:55 +0000)]
Fix build following codegen patch

15 years agoRemoved warnings, made Haddock happy, added examples in documentation
dias@eecs.harvard.edu [Fri, 17 Oct 2008 17:07:07 +0000 (17:07 +0000)]
Removed warnings, made Haddock happy, added examples in documentation
The interesting examples talk about our story with heap checks in
case alternatives and our story with the case scrutinee as a Boolean.

15 years agoFixed linear regalloc bug, dropped some tracing code
dias@eecs.harvard.edu [Thu, 16 Oct 2008 10:42:18 +0000 (10:42 +0000)]
Fixed linear regalloc bug, dropped some tracing code
o The linear-scan register allocator sometimes allocated a block
  before allocating one of its predecessors, which could lead
  to inconsistent allocations. Now, we allocate a block only
  if a predecessor has set the "incoming" assignments for the block
  (or if it's the procedure's entry block).
o Also commented out some tracing code on the new codegen path.

15 years agoKeep update frames live even in functions that never return
dias@eecs.harvard.edu [Tue, 14 Oct 2008 16:54:37 +0000 (16:54 +0000)]
Keep update frames live even in functions that never return
An unusual case, but without it:
(a) we had an assertion failure
(b) we can overwrite the caller's infotable, which might cause
    the garbage collector to collect live data.
Better to keep the update frame live at all call sites,
not just at returns.

15 years agoRemoved space and time inefficiency in procpoint splitting
dias@eecs.harvard.edu [Tue, 14 Oct 2008 16:03:54 +0000 (16:03 +0000)]
Removed space and time inefficiency in procpoint splitting
I was adding extra jumps to every procpoint, even when the split-off graph
referred to only some of the procpoints. No effect on correctness,
but a big effect on space/time efficiency when there are lots of procpoints...

15 years agoClarify the SRT building process
dias@eecs.harvard.edu [Tue, 14 Oct 2008 14:02:02 +0000 (14:02 +0000)]
Clarify the SRT building process
Before: building a closure that would build an SRT given the top-level
SRT. It was somewhat difficult to understand the control flow, and it
may have had held onto some data structures long after they should be dead.
Now, I just bundle the info we need about CAFs along with the procedure
and directly call a new top-level function to build the SRTs later.

15 years agoDon't adjust hp up when the case scrutinee won't allocate
dias@eecs.harvard.edu [Tue, 14 Oct 2008 11:26:18 +0000 (11:26 +0000)]
Don't adjust hp up when the case scrutinee won't allocate

If the case scrutinee can't allocate, we don't need to do a heap
check in the case alternatives. (A previous patch got that right.)
In that case, we had better not adjust the heap pointer to recover
unused stack space before evaluating the scrutinee -- because we
aren't going to reallocate for the case alternative.

15 years agoFloating infotables were reversed in C back end
dias@eecs.harvard.edu [Mon, 13 Oct 2008 15:27:18 +0000 (15:27 +0000)]
Floating infotables were reversed in C back end

15 years agoforgot a few files
dias@eecs.harvard.edu [Mon, 13 Oct 2008 13:42:51 +0000 (13:42 +0000)]
forgot a few files

15 years agoBig collection of patches for the new codegen branch.
dias@eecs.harvard.edu [Mon, 13 Oct 2008 13:25:56 +0000 (13:25 +0000)]
Big collection of patches for the new codegen branch.
o Fixed bug that emitted the copy-in code for closure entry
  in the wrong place -- at the initialization of the closure.
o Refactored some of the closure entry code.
o Added code to check that no LocalRegs are live-in to a procedure
   -- trip up some buggy programs earlier
o Fixed environment bindings for thunks
   -- we weren't (re)binding the free variables in a thunk
o Fixed a bug in proc-point splitting that dropped some updates
  to the entry block in a procedure.
o Fixed improper calls to code that generates CmmLit's for strings
o New invariant on cg_loc in CgIdInfo: the expression is always tagged
o Code to load free vars on entry to a thunk was (wrongly) placed before
  the heap check.
o Some of the StgCmm code was redundantly passing around Id's
  along with CgIdInfo's; no more.
o Initialize the LocalReg's that point to a closure before allocating and
  initializing the closure itself -- otherwise, we have problems with
  recursive closure bindings
o BlockEnv and BlockSet types are now abstract.
o Update frames:
  - push arguments in Old call area
  - keep track of the return sp in the FCode monad
  - keep the return sp in every call, tail call, and return
      (because it might be different at different call sites,
       e.g. tail calls to the gc after a heap check are performed
            before pushing the update frame)
  - set the sp appropriately on returns and tail calls
o Reduce call, tail call, and return to a single LastCall node
o Added slow entry code, using different calling conventions on entry and tail call
o More fixes to the calling convention code.
  The tricky stuff is all about the closure environment: it must be passed in R1,
  but in non-closures, there is no such argument, so we can't treat all arguments
  the same way: the closure environment is special. Maybe the right step forward
  would be to define a different calling convention for closure arguments.
o Let-no-escapes need to be emitted out-of-line -- otherwise, we drop code.
o Respect RTS requirement of word alignment for pointers
  My stack allocation can pack sub-word values into a single word on the stack,
  but it wasn't requiring word-alignment for pointers. It does now,
  by word-aligning both pointer registers and call areas.
o CmmLint was over-aggresively ruling out non-word-aligned memory references,
  which may be kosher now that we can spill small values into a single word.
o Wrong label order on a conditional branch when compiling switches.
o void args weren't dropped in many cases.
  To help prevent this kind of mistake, I defined a NonVoid wrapper,
  which I'm applying only to Id's for now, although there are probably
  other good candidates.
o A little code refactoring: separate modules for procpoint analysis splitting,
  stack layout, and building infotables.
o Stack limit check: insert along with the heap limit check, using a symbolic
  constant (a special CmmLit), then replace it when the stack layout is known.
o Removed last node: MidAddToContext
o Adding block id as a literal: means that the lowering of the calling conventions
  no longer has to produce labels early, which was inhibiting common-block elimination.
  Will also make it easier for the non-procpoint-splitting path.
o Info tables: don't try to describe the update frame!
o Over aggressive use of NonVoid!!!!
  Don't drop the non-void args before setting the type of the closure!!!
o Sanity checking:
  Added a pass to stub dead dead slots on the stack
  (only ~10 lines with the dataflow framework)
o More sanity checking:
  Check that incoming pointer arguments are non-stubbed.
  Note: these checks are still subject to dead-code removal, but they should
  still be quite helpful.
o Better sanity checking: why stop at function arguments?
  Instead, in mkAssign, check that _any_ assignment to a pointer type is non-null
  -- the sooner the crash, the easier it is to debug.
  Still need to add the debugging flag to turn these checks on explicitly.
o Fixed yet another calling convention bug.
  This time, the calls to the GC were wrong. I've added a new convention
  for GC calls and invoked it where appropriate.
  We should really straighten out the calling convention stuff:
    some of the code (and documentation) is spread across the compiler,
    and there's some magical use of the node register that should really
    be handled (not avoided) by calling conventions.
o Switch bug: the arms in mkCmmLitSwitch weren't returning to a single join point.
o Environment shadowing problem in Stg->Cmm:
  When a closure f is bound at the top-level, we should not bind f to the
  node register on entry to the closure.
  Why? Because if the body of f contains a let-bound closure g that refers
  to f, we want to make sure that it refers to the static closure for f.
  Normally, this would all be fine, because when we compile a closure,
  we rebind free variables in the environment. But f doesn't look like
  a free variable because it's a static value. So, the binding for f
  remains in the environment when we compile g, inconveniently referring
  to the wrong thing.
  Now, I bind the variable in the local environment only if the closure is not
  bound at the top level. It's still okay to make assumptions about the
  node holding the closure environment; we just won't find the binding
  in the environment, so code that names the closure will now directly
  get the label of the static closure, not the node register holding a
  pointer to the static closure.
o Don't generate bogus Cmm code containing SRTs during the STG -> Cmm pass!
  The tables made reference to some labels that don't exist when we compute and
  generate the tables in the back end.
o Safe foreign calls need some special treatment (at least until we have the integrated
  codegen). In particular:
  o they need info tables
  o they are not procpoints -- the successor had better be in the same procedure
  o we cannot (yet) implement the calling conventions early, which means we have
    to carry the calling-conv info all the way to the end
o We weren't following the old convention when registering a module.
  Now, we use update frames to push any new modules that have to be registered
  and enter the youngest one on the stack.
  We also use the update frame machinery to specify that the return should pop
  the return address off the stack.
o At each safe foreign call, an infotable must be at the bottom of the stack,
  and the TSO->sp must point to it.
o More problems with void args in a direct call to a function:
  We were checking the args (minus voids) to check whether the call was saturated,
  which caused problems when the function really wasn't saturated because it
  took an extra void argument.
o Forgot to distinguish integer != from floating != during Stg->Cmm
o Updating slotEnv and areaMap to include safe foreign calls
  The dataflow analyses that produce the slotEnv and areaMap give
  results for each basic block, but we also need the results for
  a safe foreign call, which is a middle node.
  After running the dataflow analysis, we have another pass that
  updates the results to includ any safe foreign calls.
o Added a static flag for the debugging technique that inserts
  instructions to stub dead slots on the stack and crashes when
  a stubbed value is loaded into a pointer-typed LocalReg.
o C back end expects to see return continuations before their call sites.
  Sorted the flowgraphs appropriately after splitting.
o PrimOp calling conventions are special -- unlimited registers, no stack
  Yet another calling convention...
o More void value problems: if the RHS of a case arm is a void-typed variable,
  don't try to return it.
o When calling some primOp, they may allocate memory; if so, we need to
  do a heap check when we return from the call.

15 years agoMerging in the new codegen branch
dias@eecs.harvard.edu [Thu, 14 Aug 2008 12:40:27 +0000 (12:40 +0000)]
Merging in the new codegen branch
This merge does not turn on the new codegen (which only compiles
a select few programs at this point),
but it does introduce some changes to the old code generator.

The high bits:
1. The Rep Swamp patch is finally here.
   The highlight is that the representation of types at the
   machine level has changed.
   Consequently, this patch contains updates across several back ends.
2. The new Stg -> Cmm path is here, although it appears to have a
   fair number of bugs lurking.
3. Many improvements along the CmmCPSZ path, including:
   o stack layout
   o some code for infotables, half of which is right and half wrong
   o proc-point splitting

15 years agoMajor clean-up of HscMain.
Thomas Schilling [Tue, 25 Nov 2008 15:32:01 +0000 (15:32 +0000)]
Major clean-up of HscMain.

This patch entails a major restructuring of HscMain and a small bugfix
to MkIface (which required the restructuring in HscMain).

In MkIface:

  - mkIface* no longer outputs orphan warnings directly and also no
    longer quits GHC when -Werror is set.  Instead, errors are
    reported using the common IO (Messages, Maybe result) scheme.

In HscMain:

  - Get rid of the 'Comp' monad.  This monad was mostly GhcMonad + two
    reader arguments, a ModSummary for the currently compiled module
    and a possible old interface.  The latter actually lead to a small
    space-leak since only its hash was needed (to check whether the
    newly-generated interface file was the same as the original one).

    Functions originally of type 'Comp' now only take the arguments
    that they actually need.  This leads to slighly longer argument
    lists in some places, however, it is now much easier to see what
    is actually going on.

  - Get rid of 'myParseModule'.  Rename 'parseFile' to 'hscParse'.

  - Join 'deSugarModule' and 'hscDesugar' (keeping the latter).

  - Rename 'typecheck{Rename}Module{'}' to 'hscTypecheck{Rename}'.
    One variant keeps the renamed syntax, the other doesn't.

  - Parameterise 'HscStatus', so that 'InteractiveStatus' is just a
    different parameterisation of 'HscStatus'.

  - 'hscCompile{OneShot,Batch,Nothing,Interactive}' are now
    implemented using a (local) typeclass called 'HsCompiler'.  The
    idea is to make the common structure more obvious.  Using this
    typeclass we now have two functions 'genericHscCompile' (original
    'hscCompiler') and 'genericHscRecompile' (original 'genComp')
    describing the default pipeline.  The methods of the typeclass
    describe a sort of "hook" interface (in OO-terms this would be
    called the "template method" pattern).

    One problem with this approach is that we parameterise over the
    /result/ type which, in fact, is not actually different for
    "nothing" and "batch" mode.  To avoid functional dependencies or
    associated types, we use type tags to make them artificially
    different and parameterise the type class over the result type.
    A perhaps better approach might be to use records instead.

  - Drop some redundant 'HscEnv' arguments.  These were likely
    different from what 'getSession' would return because during
    compilation we temporarily set the module's DynFlags as well as a
    few other fields.  We now use the 'withTempSession' combinator to
    temporarily change the 'HscEnv' and automatically restore the
    original session after the enclosed action has returned (even in
    case of exceptions).

  - Rename 'hscCompile' to 'hscGenHardCode' (since that is what it
    does).

Calls in 'GHC' and 'DriverPipeline' accordingly needed small
adaptions.

15 years agoFix Trac #2799: TcType.isOverloadedTy
simonpj@microsoft.com [Tue, 25 Nov 2008 11:05:40 +0000 (11:05 +0000)]
Fix Trac #2799: TcType.isOverloadedTy

A missing case (for equality predicates) in isOverloadedTy make
bindInstsOfLocalFuns/Pats do the wrong thing.  Core Lint nailed it.

Merge to 6.10 branch.

15 years agoFix #2740: we were missing the free variables on some expressions
Simon Marlow [Tue, 25 Nov 2008 10:31:13 +0000 (10:31 +0000)]
Fix #2740: we were missing the free variables on some expressions
Particularly boolean expresions: the conditional of an 'if', and
guards, were missing their free variables.

15 years agoFix symbol macro names in Linker.c
Thorkil Naur [Fri, 21 Nov 2008 16:01:49 +0000 (16:01 +0000)]
Fix symbol macro names in Linker.c

15 years agoAdd a --machine-readable RTS flag
Ian Lynagh [Sun, 23 Nov 2008 15:21:27 +0000 (15:21 +0000)]
Add a --machine-readable RTS flag
Currently it only affects the -t flag output

15 years agoReturn errors instead of dying in myParseModule.
Thomas Schilling [Sat, 22 Nov 2008 15:41:51 +0000 (15:41 +0000)]
Return errors instead of dying in myParseModule.

15 years agoComments/Haddockification only.
Thomas Schilling [Sat, 22 Nov 2008 14:30:18 +0000 (14:30 +0000)]
Comments/Haddockification only.

15 years agoReport source span instead of just source location for unused names.
Thomas Schilling [Sat, 22 Nov 2008 14:26:41 +0000 (14:26 +0000)]
Report source span instead of just source location for unused names.

15 years agoChange 'handleFlagWarnings' to throw exceptions instead of dying.
Thomas Schilling [Sat, 22 Nov 2008 13:06:58 +0000 (13:06 +0000)]
Change 'handleFlagWarnings' to throw exceptions instead of dying.

It now uses the standard warning log and error reporting mechanism.

15 years agoDocument exported functions in main/HeaderInfo.
Thomas Schilling [Fri, 21 Nov 2008 14:53:07 +0000 (14:53 +0000)]
Document exported functions in main/HeaderInfo.

15 years agoRemove warning supression klugde in main/HeaderInfo
Thomas Schilling [Fri, 21 Nov 2008 14:41:55 +0000 (14:41 +0000)]
Remove warning supression klugde in main/HeaderInfo

15 years agoUse mutator threads to do GC, instead of having a separate pool of GC threads
Simon Marlow [Fri, 21 Nov 2008 15:12:33 +0000 (15:12 +0000)]
Use mutator threads to do GC, instead of having a separate pool of GC threads

Previously, the GC had its own pool of threads to use as workers when
doing parallel GC.  There was a "leader", which was the mutator thread
that initiated the GC, and the other threads were taken from the pool.

This was simple and worked fine for sequential programs, where we did
most of the benchmarking for the parallel GC, but falls down for
parallel programs.  When we have N mutator threads and N cores, at GC
time we would have to stop N-1 mutator threads and start up N-1 GC
threads, and hope that the OS schedules them all onto separate cores.
It practice it doesn't, as you might expect.

Now we use the mutator threads to do GC.  This works quite nicely,
particularly for parallel programs, where each mutator thread scans
its own spark pool, which is probably in its cache anyway.

There are some flag changes:

  -g<n> is removed (-g1 is still accepted for backwards compat).
  There's no way to have a different number of GC threads than mutator
  threads now.

  -q1       Use one OS thread for GC (turns off parallel GC)
  -qg<n>    Use parallel GC for generations >= <n> (default: 1)

Using parallel GC only for generations >=1 works well for sequential
programs.  Compiling an ordinary sequential program with -threaded and
running it with -N2 or more should help if you do a lot of GC.  I've
found that adding -qg0 (do parallel GC for generation 0 too) speeds up
some parallel programs, but slows down some sequential programs.
Being conservative, I left the threshold at 1.

ToDo: document the new options.

15 years agowe shouldn't update topBound in discardSparks()
Simon Marlow [Fri, 21 Nov 2008 11:35:39 +0000 (11:35 +0000)]
we shouldn't update topBound in discardSparks()

15 years agoThrow SourceErrors instead of ProgramErrors in main/HeaderInfo.
Thomas Schilling [Fri, 21 Nov 2008 14:13:39 +0000 (14:13 +0000)]
Throw SourceErrors instead of ProgramErrors in main/HeaderInfo.

Parse errors during dependency analysis or options parsing really
shouldn't kill GHC; this is particularly annoying for GHC API clients.

15 years agofix the build when !USE_MMAP
Simon Marlow [Fri, 21 Nov 2008 08:54:18 +0000 (08:54 +0000)]
fix the build when !USE_MMAP

15 years agoround the size up to a page in mmapForLinker() instead of in the caller
Simon Marlow [Thu, 20 Nov 2008 15:40:14 +0000 (15:40 +0000)]
round the size up to a page in mmapForLinker() instead of in the caller

15 years agoFix a race in the deadlock-detection code
Simon Marlow [Thu, 20 Nov 2008 11:24:38 +0000 (11:24 +0000)]
Fix a race in the deadlock-detection code
After a deadlock it was possible for the timer signal to remain off,
which meant that the next deadlock would not be detected, and the
system would hang.  Spotted by conc047(threaded2).

15 years agoerror message wibble
Simon Marlow [Thu, 20 Nov 2008 08:49:01 +0000 (08:49 +0000)]
error message wibble

15 years agoFix flag name -XDisambiguateRecordFields
simonpj@microsoft.com [Thu, 20 Nov 2008 12:32:05 +0000 (12:32 +0000)]
Fix flag name -XDisambiguateRecordFields

15 years agoFix regTableToCapability() if gcc introduces padding
Simon Marlow [Wed, 19 Nov 2008 16:29:10 +0000 (16:29 +0000)]
Fix regTableToCapability() if gcc introduces padding
Also avoid padding if possible using __attribute__((packed))
Fixes the Windows build

15 years agoFix 32-bit breakage
Simon Marlow [Wed, 19 Nov 2008 14:54:29 +0000 (14:54 +0000)]
Fix 32-bit breakage

15 years agoSmall refactoring, and add comments
Simon Marlow [Wed, 19 Nov 2008 14:37:02 +0000 (14:37 +0000)]
Small refactoring, and add comments
I discovered a new invariant while experimenting (blackholing is not
optional when using parallel GC), so documented it.

15 years agoFix some unsigned comparisions that should be signed
Simon Marlow [Wed, 19 Nov 2008 14:32:05 +0000 (14:32 +0000)]
Fix some unsigned comparisions that should be signed
Fixes crashes when using reclaimSpark() (not used currently, but may
be in the future).

15 years agoRemove incorrect assertions in steal()
Simon Marlow [Wed, 19 Nov 2008 14:30:43 +0000 (14:30 +0000)]
Remove incorrect assertions in steal()

15 years agodon't run sparks if there are other threads on this Capability
Simon Marlow [Fri, 14 Nov 2008 12:10:22 +0000 (12:10 +0000)]
don't run sparks if there are other threads on this Capability

15 years agoFix typo (HAVE_LIBGMP => HAVE_LIB_GMP); omit local gmp includes if HAVE_LIB_GMP
Simon Marlow [Wed, 19 Nov 2008 13:10:56 +0000 (13:10 +0000)]
Fix typo (HAVE_LIBGMP => HAVE_LIB_GMP); omit local gmp includes if HAVE_LIB_GMP
If we're using the system's installed GMP, we don't want to be picking
up the local gmp.h header file.

Fixes 2469(ghci) for me, because it turns out the system's GMP is more
up-to-date than GHC's version and has a fix for more recent versions
of gcc.  We also need to pull in a more recent GMP, but that's a
separte issue.

15 years agoFix some more shutdown races
Simon Marlow [Wed, 19 Nov 2008 12:48:48 +0000 (12:48 +0000)]
Fix some more shutdown races
There were races between workerTaskStop() and freeTaskManager(): we
need to be sure that all Tasks have exited properly before we start
tearing things down.  This isn't completely straighforward, see
comments for details.

15 years agoAdd help messages about --with-editline-(includes,libraries) to the ghc configure...
Judah Jacobson [Fri, 14 Nov 2008 18:33:34 +0000 (18:33 +0000)]
Add help messages about --with-editline-(includes,libraries) to the ghc configure script.

15 years agoAdd optional eager black-holing, with new flag -feager-blackholing
Simon Marlow [Tue, 18 Nov 2008 14:24:42 +0000 (14:24 +0000)]
Add optional eager black-holing, with new flag -feager-blackholing

Eager blackholing can improve parallel performance by reducing the
chances that two threads perform the same computation.  However, it
has a cost: one extra memory write per thunk entry.

To get the best results, any code which may be executed in parallel
should be compiled with eager blackholing turned on.  But since
there's a cost for sequential code, we make it optional and turn it on
for the parallel package only.  It might be a good idea to compile
applications (or modules) with parallel code in with
-feager-blackholing.

ToDo: document -feager-blackholing.

15 years agoFix #2783: detect black-hole loops properly
Simon Marlow [Mon, 17 Nov 2008 14:45:15 +0000 (14:45 +0000)]
Fix #2783: detect black-hole loops properly
At some point we regressed on detecting simple black-hole loops.  This
happened due to the introduction of duplicate-work detection for
parallelism: a black-hole loop looks very much like duplicate work,
except it's duplicate work being performed by the very same thread.
So we have to detect and handle this case.

15 years agoFix warning on Windows (use deleteThread() not deleteThread_())
Simon Marlow [Mon, 17 Nov 2008 14:30:47 +0000 (14:30 +0000)]
Fix warning on Windows (use deleteThread() not deleteThread_())

15 years agofix compile breakage on Windows
Simon Marlow [Mon, 17 Nov 2008 14:28:31 +0000 (14:28 +0000)]
fix compile breakage on Windows

15 years agoAttempt to fix #2512 and #2063; add +RTS -xm<address> -RTS option
Simon Marlow [Mon, 17 Nov 2008 12:05:56 +0000 (12:05 +0000)]
Attempt to fix #2512 and #2063;  add +RTS -xm<address> -RTS option
On x86_64, the RTS needs to allocate memory in the low 2Gb of the
address space.  On Linux we can do this with MAP_32BIT, but sometimes
this doesn't work (#2512) and other OSs don't support it at all
(#2063).  So to work around this:

  - Try MAP_32BIT first, if available.

  - Otherwise, try allocating memory from a fixed address (by default
    1Gb)

  - We now provide an option to configure the address to allocate
    from.  This allows a workaround on machines where the default
    breaks, and also provides a way for people to test workarounds
    that we can incorporate in future releases.

15 years agoAnother shutdown fix
Simon Marlow [Mon, 17 Nov 2008 09:43:50 +0000 (09:43 +0000)]
Another shutdown fix
If we encounter a runnable thread during shutdown, just kill it.  All
the threads are supposed to be dead at this stage, but this catches
threads that might have just returned from a foreign call, or were
finalizers created by the GC.

Fixes memo002(threaded1)

15 years agoCorrect an example in the users guide
Ian Lynagh [Sun, 16 Nov 2008 17:49:38 +0000 (17:49 +0000)]
Correct an example in the users guide

15 years agoFix gen_contents_index when not run inplace; trac #2764
Ian Lynagh [Sun, 16 Nov 2008 17:41:22 +0000 (17:41 +0000)]
Fix gen_contents_index when not run inplace; trac #2764
Based on a patch from juhpetersen.

15 years agoclose the temporary Handle before removing the file
Simon Marlow [Fri, 14 Nov 2008 13:09:58 +0000 (13:09 +0000)]
close the temporary Handle before removing the file

15 years agorefactor: move unlockClosure() into SMPClosureOps() where it should be
Simon Marlow [Fri, 14 Nov 2008 09:58:17 +0000 (09:58 +0000)]
refactor: move unlockClosure() into SMPClosureOps() where it should be

15 years agoOmit definitions of cas() and xchg() in .hc code
Simon Marlow [Fri, 14 Nov 2008 09:57:38 +0000 (09:57 +0000)]
Omit definitions of cas() and xchg() in .hc code
They cause compilation errors (correctly) with newer gccs
Shows up compiling the RTS via C, which happens on Windows

15 years agoDon't put stdin into non-blocking mode (#2778, #2777)
Simon Marlow [Fri, 14 Nov 2008 13:05:46 +0000 (13:05 +0000)]
Don't put stdin into non-blocking mode (#2778, #2777)
This used to be necessary when our I/O library needed all FDs in
O_NONBLOCK mode, and readline used to put stdin back into blocking
mode.  Nowadays the I/O library can cope with FDs in blocking mode,
and #2778/#2777 show why this is important.

15 years agoRmoeve --enable-dotnet
Simon Marlow [Fri, 14 Nov 2008 12:49:29 +0000 (12:49 +0000)]
Rmoeve --enable-dotnet

15 years ago#2751: disourage --enable-shared in ./configure --help
Simon Marlow [Fri, 14 Nov 2008 12:47:48 +0000 (12:47 +0000)]
#2751: disourage --enable-shared in ./configure --help

15 years agoadd a warning that --enable-shared is experimental
Simon Marlow [Fri, 14 Nov 2008 10:40:34 +0000 (10:40 +0000)]
add a warning that --enable-shared is experimental

15 years agolookupSymbol: revert to looking up both with and without the @N suffix
Simon Marlow [Thu, 13 Nov 2008 12:29:27 +0000 (12:29 +0000)]
lookupSymbol: revert to looking up both with and without the @N suffix

15 years ago#2768: fix compatibility problem with newer version of mingw
Simon Marlow [Thu, 13 Nov 2008 11:46:26 +0000 (11:46 +0000)]
#2768: fix compatibility problem with newer version of mingw

15 years agonotice ^C exceptions when waiting for I/O
Simon Marlow [Thu, 13 Nov 2008 11:43:42 +0000 (11:43 +0000)]
notice ^C exceptions when waiting for I/O

15 years agoFix a bug in the recompilation checking logic.
Thomas Schilling [Thu, 13 Nov 2008 16:26:53 +0000 (16:26 +0000)]
Fix a bug in the recompilation checking logic.

Previously, using target HscNothing resulted in unnessesary
recompilation because 'upsweep_mod' treated HscInterface specially.
This patch changes relaxes this.

When running GHC with debug level 5, 'upsweep_mod' will now also be
more verbose about what it is doing.

There is (at least) one possible remaining problem, though: When using
target 'HscNothing' we generate a fake linkable to signal that we have
processed a module.  When switching to 'HscInterpreted' this may cause
objects to not be recompiled.  Switching from HscNothing to
HscInterpreted is therefore only safe if we unload everything first.

15 years agoFix another subtle shutdown deadlock
Simon Marlow [Thu, 13 Nov 2008 16:00:05 +0000 (16:00 +0000)]
Fix another subtle shutdown deadlock
The problem occurred when a thread tries to GC during shutdown.  In
order to GC it has to acquire all the Capabilities in the system, but
during shutdown, some of the Capabilities have already been closed and
can never be acquired.

15 years agoFix an extremely subtle deadlock bug on x86_64
Simon Marlow [Thu, 13 Nov 2008 15:57:30 +0000 (15:57 +0000)]
Fix an extremely subtle deadlock bug on x86_64
The recent_activity flag was an unsigned int, but we sometimes do a
64-bit xchg() on it, which overwrites the next word in memory.  This
happened to contain the sched_state flag, which is used to control the
orderly shutdown of the system.  If the xchg() happened during
shutdown, the scheduler would get confused and deadlock.  Don't you
just love C?