summaryrefslogtreecommitdiff
path: root/ghc/compiler/codeGen/CgHeapery.lhs
Commit message (Collapse)AuthorAgeFilesLines
* Reorganisation of the source treeSimon Marlow2006-04-071-588/+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.
* make the smp way RTS-only, normal libraries now work with -smpSimon Marlow2006-02-081-3/+1
| | | | | | | | | | | | | | We had to bite the bullet here and add an extra word to every thunk, to enable running ordinary libraries on SMP. Otherwise, we would have needed to ship an extra set of libraries with GHC 6.6 in addition to the two sets we already ship (normal + profiled), and all Cabal packages would have to be compiled for SMP too. We decided it best just to take the hit now, making SMP easily accessible to everyone in GHC 6.6. Incedentally, although this increases allocation by around 12% on average, the performance hit is around 5%, and much less if your inner loop doesn't use any laziness.
* [project @ 2005-06-21 10:44:37 by simonmar]simonmar2005-06-211-7/+5
| | | | | | | | | | | | | | | | | | | | | | | Relax the restrictions on conflicting packages. This should address many of the traps that people have been falling into with the current package story. Now, a local module can shadow a module in an exposed package, as long as the package is not otherwise required by the program. GHC checks for conflicts when it knows the dependencies of the module being compiled. Also, we now check for module conflicts in exposed packages only when importing a module: if an import can be satisfied from multiple packages, that's an error. It's not possible to prevent GHC from starting by installing packages now (unless you install another base package). It seems to be possible to confuse GHCi by having a local module shadowing a package module that goes away and comes back again. I think it's nearly right, but strange happenings have been observed. I'll try to merge this into the STABLE branch.
* [project @ 2005-04-21 15:28:20 by simonmar]simonmar2005-04-211-6/+12
| | | | | | SMP: thunks get an extra header word so that the payload doesn't occupy the same space as the updated value. This is the sum total of the changes to compiler/, which are pleasingly few.
* [project @ 2005-03-31 10:16:33 by simonmar]simonmar2005-03-311-4/+4
| | | | | | | Tweaks to get the GHC sources through Haddock. Doesn't quite work yet, because Haddock complains about the recursive modules. Haddock needs to understand SOURCE imports (it can probably just ignore them as a first attempt).
* [project @ 2005-03-18 13:37:27 by simonmar]simonmar2005-03-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flags cleanup. Basically the purpose of this commit is to move more of the compiler's global state into DynFlags, which is moving in the direction we need to go for the GHC API which can have multiple active sessions supported by a single GHC instance. Before: $ grep 'global_var' */*hs | wc -l 78 After: $ grep 'global_var' */*hs | wc -l 27 Well, it's an improvement. Most of what's left won't really affect our ability to host multiple sessions. Lots of static flags have become dynamic flags (yay!). Notably lots of flags that we used to think of as "driver" flags, like -I and -L, are now dynamic. The most notable static flags left behind are the "way" flags, eg. -prof. It would be nice to fix this, but it isn't urgent. On the way, lots of cleanup has happened. Everything related to static and dynamic flags lives in StaticFlags and DynFlags respectively, and they share a common command-line parser library in CmdLineParser. The flags related to modes (--makde, --interactive etc.) are now private to the front end: in fact private to Main itself, for now.
* [project @ 2005-02-10 13:01:52 by simonmar]simonmar2005-02-101-18/+29
| | | | | | | | | | | | | | | | | | | | | | | GC changes: instead of threading old-generation mutable lists through objects in the heap, keep it in a separate flat array. This has some advantages: - the IND_OLDGEN object is now only 2 words, so the minimum size of a THUNK is now 2 words instead of 3. This saves some amount of allocation (about 2% on average according to my measurements), and is more friendly to the cache by squashing objects together more. - keeping the mutable list separate from the IND object will be necessary for our multiprocessor implementation. - removing the mut_link field makes the layout of some objects more uniform, leading to less complexity and special cases. - I also unified the two mutable lists (mut_once_list and mut_list) into a single mutable list, which lead to more simplifications in the GC.
* [project @ 2004-11-26 16:19:45 by simonmar]simonmar2004-11-261-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Further integration with the new package story. GHC now supports pretty much everything in the package proposal. - GHC now works in terms of PackageIds (<pkg>-<version>) rather than just package names. You can still specify package names without versions on the command line, as long as the name is unambiguous. - GHC understands hidden/exposed modules in a package, and will refuse to import a hidden module. Also, the hidden/eposed status of packages is taken into account. - I had to remove the old package syntax from ghc-pkg, backwards compatibility isn't really practical. - All the package.conf.in files have been rewritten in the new syntax, and contain a complete list of modules in the package. I've set all the versions to 1.0 for now - please check your package(s) and fix the version number & other info appropriately. - New options: -hide-package P sets the expose flag on package P to False -ignore-package P unregisters P for this compilation For comparison, -package P sets the expose flag on package P to True, and also causes P to be linked in eagerly. -package-name is no longer officially supported. Unofficially, it's a synonym for -ignore-package, which has more or less the same effect as -package-name used to. Note that a package may be hidden and yet still be linked into the program, by virtue of being a dependency of some other package. To completely remove a package from the compiler's internal database, use -ignore-package. The compiler will complain if any two packages in the transitive closure of exposed packages contain the same module. You *must* use -ignore-package P when compiling modules for package P, if package P (or an older version of P) is already registered. The compiler will helpfully complain if you don't. The fptools build system does this. - Note: the Cabal library won't work yet. It still thinks GHC uses the old package config syntax. Internal changes/cleanups: - The ModuleName type has gone away. Modules are now just (a newtype of) FastStrings, and don't contain any package information. All the package-related knowledge is in DynFlags, which is passed down to where it is needed. - DynFlags manipulation has been cleaned up somewhat: there are no global variables holding DynFlags any more, instead the DynFlags are passed around properly. - There are a few less global variables in GHC. Lots more are scheduled for removal. - -i is now a dynamic flag, as are all the package-related flags (but using them in {-# OPTIONS #-} is Officially Not Recommended). - make -j now appears to work under fptools/libraries/. Probably wouldn't take much to get it working for a whole build.
* [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-266/+469
| | | | Merge backend-hacking-branch onto HEAD. Yay!
* [project @ 2003-07-28 16:05:30 by simonmar]simonmar2003-07-281-37/+2
| | | | | | | | | | | Disable update-in-place. In its current form, it has a serious bug: if the thunk being updated happens to have turned into a BLACKHOLE_BQ, then the mutable list will be corrupted by the update. Disabling update-in-place has some performance implications: many programs are not affected, but one program in nofib (nucleic2) goes about 20% slower. However, I can get it to go 300% faster by adding a few strictness annotations and compiling with -funbox-strict-fields.
* [project @ 2003-07-18 14:39:05 by simonmar]simonmar2003-07-181-4/+8
| | | | | | | | | | | When doing update-in-place, there is a (small) chance that the thunk may have been blackholed and another thread might be waiting on it. We can't therefore just splat it with the value; we have to check whether it is a blocking queue and awaken any threads that might be waiting on it if so. Should fix the scavenge_mutable_list crash reported recently. If it does, it will be merged to STABLE.
* [project @ 2003-07-02 13:12:33 by simonpj]simonpj2003-07-021-71/+54
| | | | | | | | | | | | | | | | ------------------------ 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 @ 2002-12-18 16:15:43 by simonmar]simonmar2002-12-181-7/+4
| | | | Comment fix.
* [project @ 2002-12-11 15:36:20 by simonmar]simonmar2002-12-111-217/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-20/+14
| | | | | | | | | | 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 @ 2002-08-29 15:44:11 by simonmar]simonmar2002-08-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Housekeeping: - The main goal is to remove dependencies on hslibs for a bootstrapped compiler, leaving only a requirement that the packages base, haskell98 and readline are built in stage 1 in order to bootstrap. We're almost there: Posix is still required for signal handling, but all other dependencies on hslibs are now gone. Uses of Addr and ByteArray/MutableByteArray array are all gone from the compiler. PrimPacked defines the Ptr type for GHC 4.08 (which didn't have it), and it defines simple BA and MBA types to replace uses of ByteArray and MutableByteArray respectively. - Clean up import lists. HsVersions.h now defines macros for some modules which have moved between GHC versions. eg. one now imports 'GLAEXTS' to get at unboxed types and primops in the compiler. Many import lists have been sorted as per the recommendations in the new style guidelines in the commentary. I've built the compiler with GHC 4.08.2, 5.00.2, 5.02.3, 5.04 and itself, and everything still works here. Doubtless I've got something wrong, though.
* [project @ 2002-04-29 14:03:38 by simonmar]simonmar2002-04-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [project @ 2002-02-05 14:39:24 by simonpj]simonpj2002-02-051-2/+2
| | | | Imports only
* [project @ 2001-12-12 12:19:11 by simonmar]simonmar2001-12-121-2/+8
| | | | shiftery #ifdefs
* [project @ 2001-11-23 11:57:59 by simonmar]simonmar2001-11-231-14/+5
| | | | | | | | | | | | | | | | | | | | | | | | Fix a long-standing bug in the cost attribution of cost-center stacks. The problem case is this: let z = _scc_ "z" f x in ... z ... previously we were attributing the cost of allocating the closure 'z' to the enclosing cost center stack (CCCS), when it should really be attributed to "z":CCCS. The effects are particularly visible with retainer profiling, because the closure retaining 'f' and 'x' would show up with the wrong CCS attached. To fix this, we need a new form of CCS representation internally: 'PushCC CostCentre CostCentreStack' which subsumes (and therefore replaces) SingletonCCS. SingletonCCS is now represented by 'PushCC cc NoCCS'. The CCS argument to SET_HDR may now be an arbitrary expression, such as PushCostCentre(CCCS,foo_cc), as may be the argument to CCS_ALLOC(). So we combine SET_HDR and CCS_ALLOC into a single macro, SET_HDR_, to avoid repeated calls to PushCostCentre().
* [project @ 2001-11-19 16:34:12 by simonpj]simonpj2001-11-191-2/+1
| | | | Tidy up imports
* [project @ 2001-11-08 12:50:07 by simonmar]simonmar2001-11-081-16/+5
| | | | Remove the heap-check-size panic, following the RTS fixes for this problem.
* [project @ 2000-11-06 08:15:20 by simonpj]simonpj2000-11-061-3/+2
| | | | Dealing with instance-decl imports; and removing unnecessary imports
* [project @ 2000-10-24 08:40:09 by simonpj]simonpj2000-10-241-13/+13
| | | | Small wibbles
* [project @ 2000-07-26 14:48:16 by simonmar]simonmar2000-07-261-5/+16
| | | | | | Panic if we try to allocate more than a block's worth of memory in one go. No fix yet, but at least this is better than going into an infinite loop at runtime.
* [project @ 2000-07-14 08:14:53 by simonpj]simonpj2000-07-141-3/+1
| | | | Remove dead code
* [project @ 2000-07-11 16:03:37 by simonmar]simonmar2000-07-111-2/+1
| | | | remove unused imports; misc cleanup
* [project @ 2000-01-13 14:33:57 by hwloidl]hwloidl2000-01-131-15/+20
| | | | | Merged GUM-4-04 branch into the main trunk. In particular merged GUM and SMP code. Most of the GranSim code in GUM-4-04 still has to be carried over.
* [project @ 1999-10-13 16:39:10 by simonmar]simonmar1999-10-131-12/+35
| | | | | | | 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.
* [project @ 1999-06-24 13:04:13 by simonmar]simonmar1999-06-241-4/+35
| | | | | | - Implement update-in-place in certain very specialised circumstances - Clean up abstract C a bit - Speed up pretty-printing absC a bit.
* [project @ 1999-05-26 14:12:07 by simonmar]simonmar1999-05-261-1/+4
| | | | Several bugfixes (from SLPJ's tree).
* [project @ 1999-05-13 17:30:50 by simonm]simonm1999-05-131-5/+15
| | | | | | | | | | | | | 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 @ 1999-03-08 17:05:41 by simonm]simonm1999-03-081-2/+2
| | | | Fix bug in mkRegLiveness causing bogus heap checks to be generated on the Sparc.
* [project @ 1999-03-02 16:09:28 by simonm]simonm1999-03-021-6/+5
| | | | Add missing default case to mkRegLiveness.
* [project @ 1999-01-26 16:16:19 by simonm]simonm1999-01-261-4/+2
| | | | | - Add specialised closure types (CONSTR_p_n, THUNK_p_n, FUN_p_n) - Add -T<n> RTS flag to specify the number of steps in younger generations.
* [project @ 1999-01-21 10:31:41 by simonm]simonm1999-01-211-30/+4
| | | | | Resurrect ticky-ticky profiling. Not quite polished yet, but it compiles and produces some reasonable-looking stats.
* [project @ 1998-12-18 17:40:31 by simonpj]simonpj1998-12-181-3/+2
| | | | | | | | | | | | | | | | | | | | | 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-84/+319
| | | | Move 4.01 onto the main trunk.
* [project @ 1998-01-08 18:03:08 by simonm]simonm1998-01-081-4/+2
| | | | | | | | | | | | | | | | | | | 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-05-19 00:12:10 by sof]sof1997-05-191-2/+2
| | | | 2.04 changes
* [project @ 1996-06-30 15:56:44 by partain]partain1996-06-301-1/+0
| | | | 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-1/+1
| | | | SLPJ changes through 960604
* [project @ 1996-05-17 16:02:43 by partain]partain1996-05-171-55/+39
| | | | Sansom 1.3 changes through 960507
* [project @ 1996-04-05 08:26:04 by partain]partain1996-04-051-15/+16
| | | | Add SLPJ/WDP 1.3 changes through 960404
* [project @ 1996-03-19 08:58:34 by partain]partain1996-03-191-69/+69
| | | | simonpj/sansom/partain/dnt 1.3 compiler stuff through 96/03/18
* [project @ 1996-01-08 20:28:12 by partain]partain1996-01-081-0/+278
Initial revision