1. 13 Aug, 2004 1 commit
  2. 02 Jul, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-07-02 13:12:33 by simonpj] · 3f5e4368
      simonpj authored
      ------------------------
             Tidy up the code generator
      	------------------------
      
      The code generation for 'case' expressions had grown
      huge and gnarly.  This commit removes about 120 lines of
      code, and makes it a lot easier to read too. I think the code
      generated is identical.
      
      Part of this was to simplify the StgCase data type, so
      that it is more like the Core case: there is a simple list
      of alternatives, and the DEFAULT (if present) must be the
      first.  This tidies and simplifies other Stg passes.
      3f5e4368
  3. 14 May, 2003 1 commit
    • simonmar's avatar
      [project @ 2003-05-14 09:13:52 by simonmar] · 7a236a56
      simonmar authored
      Change the way SRTs are represented:
      
      Previously, the SRT associated with a function or thunk would be a
      sub-list of the enclosing top-level function's SRT.  But this approach
      can lead to lots of duplication: if a CAF is referenced in several
      different thunks, then it may appear several times in the SRT.
      Let-no-escapes compound the problem, because the occurrence of a
      let-no-escape-bound variable would expand to all the CAFs referred to
      by the let-no-escape.
      
      The new way is to describe the SRT associated with a function or thunk
      as a (pointer+offset,bitmap) pair, where the pointer+offset points
      into some SRT table (the enclosing function's SRT), and the bitmap
      indicates which entries in this table are "live" for this closure.
      The bitmap is stored in the 16 bits previously used for the length
      field, but this rarely overflows.  When it does overflow, we store the
      bitmap externally in a new "SRT descriptor".
      
      Now the enclosing SRT can be a set, hence eliminating the duplicates.
      
      Also, we now have one SRT per top-level function in a recursive group,
      where previously we used to have one SRT for the whole group.  This
      helps keep the size of SRTs down.
      
      Bottom line: very little difference most of the time.  GHC itself got
      slightly smaller.  One bad case of a module in GHC which had a huge
      SRT has gone away.
      
      While I was in the area:
      
        - Several parts of the back-end require bitmaps.  Functions for
          creating bitmaps are now centralised in the Bitmap module.
      
        - We were trying to be independent of word-size in a couple of
          places in the back end, but we've now abandoned that strategy so I
          simplified things a bit.
      7a236a56
  4. 07 Jan, 2003 1 commit
  5. 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
  6. 13 Sep, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-09-13 15:02:25 by simonpj] · 9af77fa4
      simonpj authored
      --------------------------------------
      	Make Template Haskell into the HEAD
      	--------------------------------------
      
      This massive commit transfers to the HEAD all the stuff that
      Simon and Tim have been doing on Template Haskell.  The
      meta-haskell-branch is no more!
      
      WARNING: make sure that you
      
        * Update your links if you are using link trees.
          Some modules have been added, some have gone away.
      
        * Do 'make clean' in all library trees.
          The interface file format has changed, and you can
          get strange panics (sadly) if GHC tries to read old interface files:
          e.g.  ghc-5.05: panic! (the `impossible' happened, GHC version 5.05):
      	  Binary.get(TyClDecl): ForeignType
      
        * You need to recompile the rts too; Linker.c has changed
      
      
      However the libraries are almost unaltered; just a tiny change in
      Base, and to the exports in Prelude.
      
      
      NOTE: so far as TH itself is concerned, expression splices work
      fine, but declaration splices are not complete.
      
      
      		---------------
      		The main change
      		---------------
      
      The main structural change: renaming and typechecking have to be
      interleaved, because we can't rename stuff after a declaration splice
      until after we've typechecked the stuff before (and the splice
      itself).
      
      * Combine the renamer and typecheker monads into one
      	(TcRnMonad, TcRnTypes)
        These two replace TcMonad and RnMonad
      
      * Give them a single 'driver' (TcRnDriver).  This driver
        replaces TcModule.lhs and Rename.lhs
      
      * The haskell-src library package has a module
      	Language/Haskell/THSyntax
        which defines the Haskell data type seen by the TH programmer.
      
      * New modules:
      	hsSyn/Convert.hs 	converts THSyntax -> HsSyn
      	deSugar/DsMeta.hs 	converts HsSyn -> THSyntax
      
      * New module typecheck/TcSplice type-checks Template Haskell splices.
      
      		-------------
      		Linking stuff
      		-------------
      
      * ByteCodeLink has been split into
      	ByteCodeLink	(which links)
      	ByteCodeAsm	(which assembles)
      
      * New module ghci/ObjLink is the object-code linker.
      
      * compMan/CmLink is removed entirely (was out of place)
        Ditto CmTypes (which was tiny)
      
      * Linker.c initialises the linker when it is first used (no need to call
        initLinker any more).  Template Haskell makes it harder to know when
        and whether to initialise the linker.
      
      
      	-------------------------------------
      	Gathering the LIE in the type checker
      	-------------------------------------
      
      * Instead of explicitly gathering constraints in the LIE
      	tcExpr :: RenamedExpr -> TcM (TypecheckedExpr, LIE)
        we now dump the constraints into a mutable varabiable carried
        by the monad, so we get
      	tcExpr :: RenamedExpr -> TcM TypecheckedExpr
      
        Much less clutter in the code, and more efficient too.
        (Originally suggested by Mark Shields.)
      
      
      		-----------------
      		Remove "SysNames"
      		-----------------
      
      Because the renamer and the type checker were entirely separate,
      we had to carry some rather tiresome implicit binders (or "SysNames")
      along inside some of the HsDecl data structures.  They were both
      tiresome and fragile.
      
      Now that the typechecker and renamer are more intimately coupled,
      we can eliminate SysNames (well, mostly... default methods still
      carry something similar).
      
      		-------------
      		Clean up HsPat
      		-------------
      
      One big clean up is this: instead of having two HsPat types (InPat and
      OutPat), they are now combined into one.  This is more consistent with
      the way that HsExpr etc is handled; there are some 'Out' constructors
      for the type checker output.
      
      So:
      	HsPat.InPat	--> HsPat.Pat
      	HsPat.OutPat	--> HsPat.Pat
      	No 'pat' type parameter in HsExpr, HsBinds, etc
      
      	Constructor patterns are nicer now: they use
      		HsPat.HsConDetails
      	for the three cases of constructor patterns:
      		prefix, infix, and record-bindings
      
      	The *same* data type HsConDetails is used in the type
      	declaration of the data type (HsDecls.TyData)
      
      Lots of associated clean-up operations here and there.  Less code.
      Everything is wonderful.
      9af77fa4
  7. 29 Apr, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-04-29 14:03:38 by simonmar] · b085ee40
      simonmar authored
      FastString cleanup, stage 1.
      
      The FastString type is no longer a mixture of hashed strings and
      literal strings, it contains hashed strings only with O(1) comparison
      (except for UnicodeStr, but that will also go away in due course).  To
      create a literal instance of FastString, use FSLIT("..").
      
      By far the most common use of the old literal version of FastString
      was in the pattern
      
      	  ptext SLIT("...")
      
      this combination still works, although it doesn't go via FastString
      any more.  The next stage will be to remove the need to use this
      special combination at all, using a RULE.
      
      To convert a FastString into an SDoc, now use 'ftext' instead of
      'ptext'.
      
      I've also removed all the FAST_STRING related macros from HsVersions.h
      except for SLIT and FSLIT, just use the relevant functions from
      FastString instead.
      b085ee40
  8. 03 Jan, 2002 1 commit
  9. 23 Nov, 2001 1 commit
  10. 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
  11. 26 Sep, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-09-26 15:11:50 by simonpj] · 5cd3527d
      simonpj authored
      -------------------------------
      	Code generation and SRT hygiene
      	-------------------------------
      
      This is a big tidy up commit.  I don't think it breaks anything,
      but it certainly makes the code clearer (to me).
      
      I'm not certain that you can use it without sucking in my other
      big commit... they come from the same tree.
      
      
      Core-to-STG, live variables and Static Reference Tables (SRTs)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      I did a big tidy-up of the live-variable computation in CoreToStg.
      The key idea is that the live variables consist of two parts:
      	dynamic live vars
      	static live vars (CAFs)
      
      These two always travel round together, but they were always
      treated separately by the code until now. Now it's a new data type:
      
      type LiveInfo = (StgLiveVars, 	-- Dynamic live variables;
      				-- i.e. ones with a nested (non-top-level) binding
      		 CafSet)	-- Static live variables;
      				-- i.e. top-level variables that are CAFs or refer to them
      
      There's lots of documentation in CoreToStg.
      
      Code generation
      ~~~~~~~~~~~~~~~
      Arising from this, I found that SRT labels were stored in
      a LambdaFormInfo during code generation, whereas they *ought*
      to be in the ClosureInfo (which in turn contains a LambdaFormInfo).
      
      This led to lots of changes in ClosureInfo, and I took the opportunity
      to make it into a labelled record.
      
      Similarly, I made the data type in AbstractC a bit more explicit:
      
        -- C_SRT is what StgSyn.SRT gets translated to...
        -- we add a label for the table, and expect only the 'offset/length' form
      
      data C_SRT = NoC_SRT
      	   | C_SRT CLabel !Int{-offset-} !Int{-length-}
      
      (Previously there were bottoms lying around.)
      5cd3527d
  12. 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
  13. 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
  14. 29 Aug, 2001 1 commit
    • 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
  15. 06 Nov, 2000 1 commit
  16. 04 Sep, 2000 1 commit
  17. 11 Jul, 2000 1 commit
  18. 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
  19. 09 Jun, 1999 1 commit
  20. 08 Jun, 1999 1 commit
    • 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
  21. 18 May, 1999 1 commit
  22. 13 May, 1999 1 commit
    • simonm's avatar
      [project @ 1999-05-13 17:30:50 by simonm] · 589b7946
      simonm authored
      Support for "unregisterised" builds.  An unregisterised build doesn't
      use the assembly mangler, doesn't do tail jumping (uses the
      mini-interpreter), and doesn't use global register variables.
      
      Plenty of cleanups and bugfixes in the process.
      
      Add way 'u' to GhcLibWays to get unregisterised libs & RTS.
      
      [ note: not *quite* working fully yet... there's still a bug or two
        lurking ]
      589b7946
  23. 02 Mar, 1999 1 commit
    • sof's avatar
      [project @ 1999-03-02 14:34:33 by sof] · dc7d7a2f
      sof authored
      - import list tweaks
      - moved the code that decides that a StgCon really shouldn't
        be mapped to a static constructor but an updateable thunk
        if it contains lit-lits from the codegen into the CoreToStg
        translation.
      
        Added an extra case to this code to deal with StgCon's that contain
        references to values that reside in a DLL, where we also have to
        opt for an updateable thunk instead of a static constructor. Only
        applies when compiling on/for Win32 platforms.
      dc7d7a2f
  24. 06 Jan, 1999 1 commit
  25. 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
  26. 02 Dec, 1998 1 commit
  27. 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
  28. 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
  29. 05 Jun, 1997 1 commit
  30. 26 May, 1997 1 commit
  31. 19 May, 1997 1 commit
  32. 14 Mar, 1997 1 commit
  33. 15 Jul, 1996 2 commits
  34. 26 Jun, 1996 1 commit
  35. 05 Jun, 1996 1 commit
  36. 05 Apr, 1996 1 commit
  37. 19 Mar, 1996 1 commit
  38. 11 Jan, 1996 1 commit
  39. 08 Jan, 1996 1 commit