summaryrefslogtreecommitdiff
path: root/ghc/compiler/codeGen/CgLetNoEscape.lhs
Commit message (Collapse)AuthorAgeFilesLines
* Reorganisation of the source treeSimon Marlow2006-04-071-212/+0
| | | | | | | | | | | | | | | Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.
* [project @ 2004-09-30 10:35:15 by simonpj]simonpj2004-09-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------ Add Generalised Algebraic Data Types ------------------------------------ This rather big commit adds support for GADTs. For example, data Term a where Lit :: Int -> Term Int App :: Term (a->b) -> Term a -> Term b If :: Term Bool -> Term a -> Term a ..etc.. eval :: Term a -> a eval (Lit i) = i eval (App a b) = eval a (eval b) eval (If p q r) | eval p = eval q | otherwise = eval r Lots and lots of of related changes throughout the compiler to make this fit nicely. One important change, only loosely related to GADTs, is that skolem constants in the typechecker are genuinely immutable and constant, so we often get better error messages from the type checker. See TcType.TcTyVarDetails. There's a new module types/Unify.lhs, which has purely-functional unification and matching for Type. This is used both in the typechecker (for type refinement of GADTs) and in Core Lint (also for type refinement).
* [project @ 2004-08-13 13:04:50 by simonmar]simonmar2004-08-131-32/+32
| | | | Merge backend-hacking-branch onto HEAD. Yay!
* [project @ 2003-07-21 11:01:06 by simonmar]simonmar2003-07-211-3/+5
| | | | | | | | When restoring the cost centre in a let-no-escape, don't free the stack slot containing it. We might need the saved cost centre again for a recursive call to this let-no-escape. Should fix profiling a bit more.
* [project @ 2003-07-18 16:31:27 by simonmar]simonmar2003-07-181-4/+7
| | | | | | | | | | | Restoring of cost centre in let-no-escape: we need to do this after binding the args to stack locations, otherwise we end up grabbing the wrong slot. Should hopefully fix profiling crashes. We still don't pay any attention to the cost centre attached to the let-no-escape binding itself, which looks wrong, but I don't intend to do anything about that right now.
* [project @ 2003-07-02 13:18:24 by simonpj]simonpj2003-07-021-3/+2
| | | | | | | | | | | | | | | | | | Fixes two minor bugs that I came across in the old CgCase code generation: 1. We were generating tmp = Sp[1] ... more uses of Sp[1].... instead of tmp = Sp[1] ... more uses of tmp.... in the (case v of ...prim alts...) situation 2. The cost-centre restoration wasn't right for let-no-escapes I kept this fix separate, becuase it does change the code generated slightly.
* [project @ 2003-07-02 13:12:33 by simonpj]simonpj2003-07-021-65/+28
| | | | | | | | | | | | | | | | ------------------------ 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.
* [project @ 2003-05-14 09:13:52 by simonmar]simonmar2003-05-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2002-12-11 15:36:20 by simonmar]simonmar2002-12-111-15/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2002-09-13 15:02:25 by simonpj]simonpj2002-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------------- 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.
* [project @ 2002-09-04 10:00:45 by simonmar]simonmar2002-09-041-2/+2
| | | | | | | | | | Recent changes to simplify PrimRep had introduced a bug: the heap check code was assuming that anything with PtrRep representation was enterable. This isn't the case for the unpointed primitive types (eg. ByteArray#), resulting in the ARR_WORDS crash in last night's build. This bug isn't in STABLE.
* [project @ 2001-10-25 02:13:10 by sof]sof2001-10-251-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | - Pet peeve removal / code tidyup, replaced various sub-optimal uses of 'length' with something a bit better, i.e., replaced the following patterns * length as `cmpOp` length bs * length as `cmpOp` val -- incl. uses where val == 1 and val == 0 * {take,drop,splitAt} (length as) bs * length [ () | pat <- as ] with uses of misc Util functions. I'd be surprised if there's a noticeable reduction in running times as a result of these changes, but every little bit helps. [ The changes have been tested wrt testsuite/ - I'm seeing a couple of unexpected breakages coming from CorePrep, but I'm currently assuming that these are due to other recent changes. ] - compMan/CompManager.lhs: restored 4.08 compilability + some code cleanup. None of these changes are HEADworthy.
* [project @ 2001-09-26 15:11:50 by simonpj]simonpj2001-09-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------- 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.)
* [project @ 2000-07-11 16:03:37 by simonmar]simonmar2000-07-111-2/+1
| | | | remove unused imports; misc cleanup
* [project @ 1999-05-13 17:30:50 by simonm]simonm1999-05-131-8/+9
| | | | | | | | | | | | | 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 ]
* [project @ 1998-12-18 17:40:31 by simonpj]simonpj1998-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 1998-12-02 13:17:09 by simonm]simonm1998-12-021-48/+74
| | | | Move 4.01 onto the main trunk.
* [project @ 1998-01-08 18:03:08 by simonm]simonm1998-01-081-9/+4
| | | | | | | | | | | | | | | | | | | 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.
* [project @ 1997-06-05 21:15:00 by sof]sof1997-06-051-0/+4
| | | | import updates
* [project @ 1997-05-19 00:12:10 by sof]sof1997-05-191-1/+2
| | | | 2.04 changes
* [project @ 1996-06-30 15:56:44 by partain]partain1996-06-301-1/+2
| | | | partain 1.3 changes through 960629
* [project @ 1996-06-26 10:26:00 by partain]partain1996-06-261-1/+1
| | | | SLPJ 1.3 changes through 96/06/25
* [project @ 1996-06-05 06:44:31 by partain]partain1996-06-051-6/+6
| | | | SLPJ changes through 960604
* [project @ 1996-04-05 08:26:04 by partain]partain1996-04-051-9/+12
| | | | Add SLPJ/WDP 1.3 changes through 960404
* [project @ 1996-03-19 08:58:34 by partain]partain1996-03-191-17/+17
| | | | simonpj/sansom/partain/dnt 1.3 compiler stuff through 96/03/18
* [project @ 1996-01-11 14:06:51 by partain]partain1996-01-111-4/+5
|
* [project @ 1996-01-08 20:28:12 by partain]partain1996-01-081-0/+202
Initial revision