1. 11 Dec, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-12-11 15:36:20 by simonmar] · 0bffc410
      simonmar authored
      Merge the eval-apply-branch on to the HEAD
      ------------------------------------------
      
      This is a change to GHC's evaluation model in order to ultimately make
      GHC more portable and to reduce complexity in some areas.
      
      At some point we'll update the commentary to describe the new state of
      the RTS.  Pending that, the highlights of this change are:
      
        - No more Su.  The Su register is gone, update frames are one
          word smaller.
      
        - Slow-entry points and arg checks are gone.  Unknown function calls
          are handled by automatically-generated RTS entry points (AutoApply.hc,
          generated by the program in utils/genapply).
      
        - The stack layout is stricter: there are no "pending arguments" on
          the stack any more, the stack is always strictly a sequence of
          stack frames.
      
          This means that there's no need for LOOKS_LIKE_GHC_INFO() or
          LOOKS_LIKE_STATIC_CLOSURE() any more, and GHC doesn't need to know
          how to find the boundary between the text and data segments (BIG WIN!).
      
        - A couple of nasty hacks in the mangler caused by the neet to
          identify closure ptrs vs. info tables have gone away.
      
        - Info tables are a bit more complicated.  See InfoTables.h for the
          details.
      
        - As a side effect, GHCi can now deal with polymorphic seq.  Some bugs
          in GHCi which affected primitives and unboxed tuples are now
          fixed.
      
        - Binary sizes are reduced by about 7% on x86.  Performance is roughly
          similar, some programs get faster while some get slower.  I've seen
          GHCi perform worse on some examples, but haven't investigated
          further yet (GHCi performance *should* be about the same or better
          in theory).
      
        - Internally the code generator is rather better organised.  I've moved
          info-table generation from the NCG into the main codeGen where it is
          shared with the C back-end; info tables are now emitted as arrays
          of words in both back-ends.  The NCG is one step closer to being able
          to support profiling.
      
      This has all been fairly thoroughly tested, but no doubt I've messed
      up the commit in some way.
      0bffc410
  2. 14 Mar, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-03-14 15:27:15 by simonpj] · 1553c778
      simonpj authored
      ------------------------
      	Change
      		GlobalName --> ExternalName
      		LocalName  ->  InternalName
      	------------------------
      
      For a long time there's been terminological confusion between
      
      	GlobalName vs LocalName	 (property of a Name)
      	GlobalId vs LocalId	 (property of an Id)
      
      I've now changed the terminology for Name to be
      
      	ExternalName vs InternalName
      
      I've also added quite a bit of documentation in the Commentary.
      1553c778
  3. 23 Nov, 2001 1 commit
  4. 15 Oct, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-10-15 16:03:04 by simonpj] · 5e65c9fe
      simonpj authored
      --------------------------
      	Tidy up arity propagation (the saga continues)
      	--------------------------
      
      Turns out that it's not as easy as I thought.
      
      The code generator was assuming that (not . isLocalName) was enough to
      identify an imported thing (whose CgInfo should be right), but that's
      not true.  Needs more thought.
      
      Meanwhile, I've made the code generator a bit more sensible about how
      it looks things up.  But there's still a problem for GHCi: the
      unfoldings in the TypeEnv won't have CgIdInfo stuff.  Sigh.  Thinks.
      5e65c9fe
  5. 22 Sep, 2001 1 commit
  6. 12 Sep, 2001 1 commit
    • sewardj's avatar
      [project @ 2001-09-12 15:52:40 by sewardj] · 7a846c96
      sewardj authored
      merge (ghc-5-02-branch --> HEAD):
      
      Bugfix: there was an implicit assumption that the list of slots passed
      to freeStackSlots was already sorted, whereas in fact this wasn't the
      case for at least one call.  Now we explicitly sort the list in
      freeStackSlots, removing the hidden assumption.
      
      The symptoms of this bug include crashes (perhaps the "AsmCodeGen"
      crash), and a tendency to grow the stack a lot when let-no-escapes are
      involved (because the bug caused fragmentation of the stack free list,
      so we weren't re-using free slots properly).
        1.17.2.1  +3 -2      fptools/ghc/compiler/codeGen/CgStackery.lhs
      
      
      ASSERT that the list of stack slots we calculate in buildLivenessMask
      is sorted, because we rely on that property later.
        1.38.2.1  +5 -6      fptools/ghc/compiler/codeGen/CgBindery.lhs
      7a846c96
  7. 31 Aug, 2001 1 commit
    • rje's avatar
      [project @ 2001-08-31 12:39:06 by rje] · 205383c2
      rje authored
      Reapplied my "FCode as a monad" patch, now that 5.02 has forked into
      a separate branch.
      
      I'm fairly sure that this doesn't change the behaviour of anything.
      205383c2
  8. 30 Aug, 2001 1 commit
    • sewardj's avatar
      [project @ 2001-08-30 09:51:15 by sewardj] · d6e95f7a
      sewardj authored
      Back out recent changes to the code generator as too destabilising.
      Revert files as follows:
      
      revert to 1.35   CgBindery.lhs
      revert to 1.26   CgMonad.lhs
      revert to 1.15   CgStackery.lhs
      revert to 1.10   CgUsages.lhs
      d6e95f7a
  9. 29 Aug, 2001 2 commits
    • sof's avatar
      [project @ 2001-08-29 19:29:04 by sof] · 2f3a767f
      sof authored
      make it compile.
      2f3a767f
    • rje's avatar
      [project @ 2001-08-29 14:20:14 by rje] · c31a55d1
      rje authored
      FCode/Code is now a monad, and thus now also a constructed type, rather than a
      type synonym.
      
      This requires quite a lot of changes in quite a lot of files, but none of these changes should have changed the behaviour of anything.
      
      Being a Monad allows code that used FCode to be IMHO rather more readable
      as it can use do notation, and other common Monad idioms.
      
      In addition, state has been abstracted away with getter and setter
      functions, so that functions mess with the innards of FCode as little as
      possible - making it easier to change FCode in future.
      c31a55d1
  10. 24 Jul, 2001 1 commit
    • ken's avatar
      [project @ 2001-07-24 05:04:58 by ken] · 030787e5
      ken authored
      Removed 32-bit dependencies in the generation and handling of
      liveness mask bitmaps.  We now support both 32-bit and 64-bit
      machines with identical .hc files.  Support for >64-bit machines
      would be easy to add.  Note that old .hc files are incompatible
      with the changes made to ghc/include/InfoMacros.h!
      030787e5
  11. 06 Dec, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-12-06 13:19:49 by simonmar] · b5a7f584
      simonmar authored
      Re-engineer the transition from Core to STG syntax.  Main changes in
        this commit:
      
          - a new pass, CoreSat, handles saturation of constructors and PrimOps,
            and puts the syntax into STG-like normal form (applications to atoms
            only, etc), modulo type applications and Notes.
      
          - CoreToStg is now done at the same time as StgVarInfo.  Most of the
            contents of StgVarInfo.lhs have been copied into CoreToStg.lhs and
            some simplifications made.
      
        less major changes:
      
          - globalisation of names for the purposes of object splitting is
            now done by the C code generator (which is the Right Place in
            principle, but it was a bit fiddly).
      
          - CoreTidy now does cloning of local binders and collection of arity
            info.  The IdInfo from CoreTidy is now *almost* the final IdInfo we
            put in the interface file, except for CafInfo.  I'm going to move
            the CafInfo collection into CoreTidy in due course too.
      
          - and some other minor tidyups while I was in cluster-bomb commit mode.
      b5a7f584
  12. 14 Nov, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-11-14 08:07:11 by simonpj] · db95d6e8
      simonpj authored
      Changing the way we know whether
      something is exported.
      
      THIS COMMIT WON'T EVEN COMPILE
      (I'm doing it to transfer from my laptop.)
      Wait till later today before updating.
      db95d6e8
  13. 06 Nov, 2000 1 commit
  14. 11 Jul, 2000 1 commit
  15. 23 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-23 17:45:17 by simonpj] · 111cee3f
      simonpj authored
      This utterly gigantic commit is what I've been up to in background
      mode in the last couple of months.  Originally the main goal
      was to get rid of Con (staturated constant applications)
      in the CoreExpr type, but one thing led to another, and I kept
      postponing actually committing.   Sorry.
      
      	Simon, 23 March 2000
      
      
      I've tested it pretty thoroughly, but doubtless things will break.
      
      Here are the highlights
      
      * Con is gone; the CoreExpr type is simpler
      * NoRepLits have gone
      * Better usage info in interface files => less recompilation
      * Result type signatures work
      * CCall primop is tidied up
      * Constant folding now done by Rules
      * Lots of hackery in the simplifier
      * Improvements in CPR and strictness analysis
      
      Many bug fixes including
      
      * Sergey's DoCon compiles OK; no loop in the strictness analyser
      * Volker Wysk's programs don't crash the CPR analyser
      
      I have not done much on measuring compilation times and binary sizes;
      they could have got worse.  I think performance has got significantly
      better, though, in most cases.
      
      
      Removing the Con form of Core expressions
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      The big thing is that
      
        For every constructor C there are now *two* Ids:
      
      	C is the constructor's *wrapper*. It evaluates and unboxes arguments
      	before calling $wC.  It has a perfectly ordinary top-level defn
      	in the module defining the data type.
      
      	$wC is the constructor's *worker*.  It is like a primop that simply
      	allocates and builds the constructor value.  Its arguments are the
      	actual representation arguments of the constructor.
      	Its type may be different to C, because:
      		- useless dict args are dropped
      		- strict args may be flattened
      
        For every primop P there is *one* Id, its (curried) Id
      
        Neither contructor worker Id nor the primop Id have a defminition anywhere.
        Instead they are saturated during the core-to-STG pass, and the code generator
        generates code for them directly. The STG language still has saturated
        primops and constructor applications.
      
      * The Const type disappears, along with Const.lhs.  The literal part
        of Const.lhs reappears as Literal.lhs.  Much tidying up in here,
        to bring all the range checking into this one module.
      
      * I got rid of NoRep literals entirely.  They just seem to be too much trouble.
      
      * Because Con's don't exist any more, the funny C { args } syntax
        disappears from inteface files.
      
      
      Parsing
      ~~~~~~~
      * Result type signatures now work
      	f :: Int -> Int = \x -> x
      	-- The Int->Int is the type of f
      
      	g x y :: Int = x+y
      	-- The Int is the type of the result of (g x y)
      
      
      Recompilation checking and make
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * The .hi file for a modules is not touched if it doesn't change.  (It used to
        be touched regardless, forcing a chain of recompilations.)  The penalty for this
        is that we record exported things just as if they were mentioned in the body of
        the module.  And the penalty for that is that we may recompile a module when
        the only things that have changed are the things it is passing on without using.
        But it seems like a good trade.
      
      * -recomp is on by default
      
      Foreign declarations
      ~~~~~~~~~~~~~~~~~~~~
      * If you say
      	foreign export zoo :: Int -> IO Int
        then you get a C produre called 'zoo', not 'zzoo' as before.
        I've also added a check that complains if you export (or import) a C
        procedure whose name isn't legal C.
      
      
      Code generation and labels
      ~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Now that constructor workers and wrappers have distinct names, there's
        no need to have a Foo_static_closure and a Foo_closure for constructor Foo.
        I nuked the entire StaticClosure story.  This has effects in some of
        the RTS headers (i.e. s/static_closure/closure/g)
      
      
      Rules, constant folding
      ~~~~~~~~~~~~~~~~~~~~~~~
      * Constant folding becomes just another rewrite rule, attached to the Id for the
        PrimOp.   To achieve this, there's a new form of Rule, a BuiltinRule (see CoreSyn.lhs).
        The prelude rules are in prelude/PrelRules.lhs, while simplCore/ConFold.lhs has gone.
      
      * Appending of constant strings now works, using fold/build fusion, plus
        the rewrite rule
      	unpack "foo" c (unpack "baz" c n)  =  unpack "foobaz" c n
        Implemented in PrelRules.lhs
      
      * The CCall primop is tidied up quite a bit.  There is now a data type CCall,
        defined in PrimOp, that packages up the info needed for a particular CCall.
        There is a new Id for each new ccall, with an big "occurrence name"
      	{__ccall "foo" gc Int# -> Int#}
        In interface files, this is parsed as a single Id, which is what it is, really.
      
      Miscellaneous
      ~~~~~~~~~~~~~
      * There were numerous places where the host compiler's
        minInt/maxInt was being used as the target machine's minInt/maxInt.
        I nuked all of these; everything is localised to inIntRange and inWordRange,
        in Literal.lhs
      
      * Desugaring record updates was broken: it didn't generate correct matches when
        used withe records with fancy unboxing etc.  It now uses matchWrapper.
      
      * Significant tidying up in codeGen/SMRep.lhs
      
      * Add __word, __word64, __int64 terminals to signal the obvious types
        in interface files.  Add the ability to print word values in hex into
        C code.
      
      * PrimOp.lhs is no longer part of a loop.  Remove PrimOp.hi-boot*
      
      
      Types
      ~~~~~
      * isProductTyCon no longer returns False for recursive products, nor
        for unboxed products; you have to test for these separately.
        There's no reason not to do CPR for recursive product types, for example.
        Ditto splitProductType_maybe.
      
      Simplification
      ~~~~~~~~~~~~~~~
      * New -fno-case-of-case flag for the simplifier.  We use this in the first run
        of the simplifier, where it helps to stop messing up expressions that
        the (subsequent) full laziness pass would otherwise find float out.
        It's much more effective than previous half-baked hacks in inlining.
      
        Actually, it turned out that there were three places in Simplify.lhs that
        needed to know use this flag.
      
      * Make the float-in pass push duplicatable bindings into the branches of
        a case expression, in the hope that we never have to allocate them.
        (see FloatIn.sepBindsByDropPoint)
      
      * Arrange that top-level bottoming Ids get a NOINLINE pragma
        This reduced gratuitous inlining of error messages.
        But arrange that such things still get w/w'd.
      
      * Arrange that a strict argument position is regarded as an 'interesting'
        context, so that if we see
      	foldr k z (g x)
        then we'll be inclined to inline g; this can expose a build.
      
      * There was a missing case in CoreUtils.exprEtaExpandArity that meant
        we were missing some obvious cases for eta expansion
        Also improve the code when handling applications.
      
      * Make record selectors (identifiable by their IdFlavour) into "cheap" operations.
      	  [The change is a 2-liner in CoreUtils.exprIsCheap]
        This means that record selection may be inlined into function bodies, which
        greatly improves the arities of overloaded functions.
      
      * Make a cleaner job of inlining "lone variables".  There was some distributed
        cunning, but I've centralised it all now in SimplUtils.analyseCont, which
        analyses the context of a call to decide whether it is "interesting".
      
      * Don't specialise very small functions in Specialise.specDefn
        It's better to inline it.  Rather like the worker/wrapper case.
      
      * Be just a little more aggressive when floating out of let rhss.
        See comments with Simplify.wantToExpose
        A small change with an occasional big effect.
      
      * Make the inline-size computation think that
      	case x of I# x -> ...
        is *free*.
      
      
      CPR analysis
      ~~~~~~~~~~~~
      * Fix what was essentially a bug in CPR analysis.  Consider
      
      	letrec f x = let g y = let ... in f e1
      		     in
      		     if ... then (a,b) else g x
      
        g has the CPR property if f does; so when generating the final annotated
        RHS for f, we must use an envt in which f is bound to its final abstract
        value.  This wasn't happening.  Instead, f was given the CPR tag but g
        wasn't; but of course the w/w pass gives rotten results in that case!!
        (Because f's CPR-ness relied on g's.)
      
        On they way I tidied up the code in CprAnalyse.  It's quite a bit shorter.
      
        The fact that some data constructors return a constructed product shows
        up in their CPR info (MkId.mkDataConId) not in CprAnalyse.lhs
      
      
      
      Strictness analysis and worker/wrapper
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * BIG THING: pass in the demand to StrictAnal.saExpr.  This affects situations
        like
      	f (let x = e1 in (x,x))
        where f turns out to have strictness u(SS), say.  In this case we can
        mark x as demanded, and use a case expression for it.
      
        The situation before is that we didn't "know" that there is the u(SS)
        demand on the argument, so we simply computed that the body of the let
        expression is lazy in x, and marked x as lazily-demanded.  Then even after
        f was w/w'd we got
      
      	let x = e1 in case (x,x) of (a,b) -> $wf a b
      
        and hence
      
      	let x = e1 in $wf a b
      
        I found a much more complicated situation in spectral/sphere/Main.shade,
        which improved quite a bit with this change.
      
      * Moved the StrictnessInfo type from IdInfo to Demand.  It's the logical
        place for it, and helps avoid module loops
      
      * Do worker/wrapper for coerces even if the arity is zero.  Thus:
      	stdout = coerce Handle (..blurg..)
        ==>
      	wibble = (...blurg...)
      	stdout = coerce Handle wibble
        This is good because I found places where we were saying
      	case coerce t stdout of { MVar a ->
      	...
      	case coerce t stdout of { MVar b ->
      	...
        and the redundant case wasn't getting eliminated because of the coerce.
      111cee3f
  16. 13 Oct, 1999 1 commit
    • simonmar's avatar
      [project @ 1999-10-13 16:39:10 by simonmar] · 5c67176d
      simonmar authored
      Crude allocation-counting extension to ticky-ticky profiling.
      
      Allocations are counted against the closest lexically enclosing
      function closure, so you need to map the output back to the STG code.
      5c67176d
  17. 09 Jun, 1999 1 commit
  18. 08 Jun, 1999 2 commits
    • simonmar's avatar
      [project @ 1999-06-08 16:06:04 by simonmar] · 7dd11ebc
      simonmar authored
      Update the comment for buildLivenessMask to match reality.
      7dd11ebc
    • simonmar's avatar
      [project @ 1999-06-08 15:56:44 by simonmar] · 62812240
      simonmar authored
      Allow reserving of stack slots for non-pointer data (eg. cost
      centres).  This means the previous hacks to keep the stack bitmaps
      correct in the presence of cost centres are now unnecessary, and
      case-of-case expressions will be compiled properly with profiling on.
      62812240
  19. 22 Jan, 1999 1 commit
  20. 06 Jan, 1999 1 commit
  21. 18 Dec, 1998 1 commit
    • simonpj's avatar
      [project @ 1998-12-18 17:40:31 by simonpj] · 7e602b0a
      simonpj authored
      Another big commit from Simon.  Actually, the last one
      didn't all go into the main trunk; because of a CVS glitch it
      ended up in the wrong branch.
      
      So this commit includes:
      
      * Scoped type variables
      * Warnings for unused variables should work now (they didn't before)
      * Simplifier improvements:
      	- Much better treatment of strict arguments
      	- Better treatment of bottoming Ids
      	- No need for w/w split for fns that are merely strict
      	- Fewer iterations needed, I hope
      * Less gratuitous renaming in interface files and abs C
      * OccName is a separate module, and is an abstract data type
      
      I think the whole Prelude and Exts libraries compile correctly.
      Something isn't quite right about typechecking existentials though.
      7e602b0a
  22. 02 Dec, 1998 1 commit
  23. 19 Mar, 1998 1 commit
  24. 09 Jan, 1998 1 commit
  25. 08 Jan, 1998 1 commit
    • simonm's avatar
      [project @ 1998-01-08 18:03:08 by simonm] · 9dd6e1c2
      simonm authored
      The Great Multi-Parameter Type Classes Merge.
      
      Notes from Simon (abridged):
      
      * Multi-parameter type classes are fully implemented.
      * Error messages from the type checker should be noticeably improved
      * Warnings for unused bindings (-fwarn-unused-names)
      * many other minor bug fixes.
      
      Internally there are the following changes
      
      * Removal of Haskell 1.2 compatibility.
      * Dramatic clean-up of the PprStyle stuff.
      * The type Type has been substantially changed.
      * The dictionary for each class is represented by a new
        data type for that purpose, rather than by a tuple.
      9dd6e1c2
  26. 25 Nov, 1997 1 commit
    • sof's avatar
      [project @ 1997-11-25 18:00:56 by sof] · fc1e9b53
      sof authored
      Move StableLoc (and assoc. access functions) from CgBindery to CgMonad. Done to avoid having to give the home of Maybe in CgBindery.hi-boot.
      fc1e9b53
  27. 20 Jun, 1997 1 commit
  28. 05 Jun, 1997 1 commit
  29. 26 May, 1997 1 commit
  30. 19 May, 1997 1 commit
  31. 06 Jan, 1997 1 commit
  32. 19 Dec, 1996 1 commit
  33. 30 Jun, 1996 1 commit
  34. 26 Jun, 1996 1 commit
  35. 11 Jun, 1996 1 commit
  36. 05 Jun, 1996 1 commit
  37. 16 May, 1996 1 commit
  38. 06 May, 1996 1 commit