summaryrefslogtreecommitdiff
path: root/ghc/compiler/codeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [project @ 2005-01-23 18:50:40 by wolfgang]wolfgang2005-01-231-1/+6
| | | | | | | | | | Make the NCG distinguish between the read-only data section and the "relocatable read-only data" section. Read-only data is supposed to be _really_ read-only, whereas "relrodata" can have relocations, but should not be modified by the program at runtime. For Linux, put relrodata into ".data" by default, as the dynamic linker tends to do evil things to avoid relocating things in read-only sections.
* [project @ 2005-01-12 16:33:54 by simonmar]simonmar2005-01-121-3/+7
| | | | Fix a bug in mk_switch.
* [project @ 2004-12-08 14:32:28 by simonpj]simonpj2004-12-084-8/+9
| | | | Comments and asserts only
* [project @ 2004-11-26 16:19:45 by simonmar]simonmar2004-11-2612-156/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-11-21 22:25:23 by desrt]desrt2004-11-211-1/+1
| | | | | | | rtsconfig, smrep: fixes to not put info next to code (like ia64) machregs: define registers for powerpc64 - same as ppc32 tailcalls: for now do tailcalls as normal calls. (ok on powerpc since calls don't grow the stack and we don't care about LR anyway)
* [project @ 2004-11-18 09:56:07 by tharris]tharris2004-11-181-0/+1
| | | | Support for atomic memory transactions and associated regression tests conc041-048
* [project @ 2004-11-10 01:58:32 by wolfgang]wolfgang2004-11-101-1/+2
| | | | | | 64-bit fix: when loading the "era" global variable, convert it from cIntRep to wordRep after loading (this is a no-op on all 32-bit platforms).
* [project @ 2004-10-07 15:54:03 by wolfgang]wolfgang2004-10-071-19/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Position Independent Code and Dynamic Linking Support, Part 1 This commit allows generation of position independent code (PIC) that fully supports dynamic linking on Mac OS X and PowerPC Linux. Other platforms are not yet supported, and there is no support for actually linking or using dynamic libraries - so if you use the -fPIC or -dynamic code generation flags, you have to type your (platform-specific) linker command lines yourself. nativeGen/PositionIndependentCode.hs: New file. Look here for some more comments on how this works. cmm/CLabel.hs: Add support for DynamicLinkerLabels and PIC base labels - for use inside the NCG. needsCDecl: Case alternative labels now need C decls, see the codeGen/CgInfoTbls.hs below for details cmm/Cmm.hs: Add CmmPicBaseReg (used in NCG), and CmmLabelDiffOff (used in NCG and for offsets in info tables) cmm/CmmParse.y: support offsets in info tables cmm/PprC.hs: support CmmLabelDiffOff Case alternative labels now need C decls (see the codeGen/CgInfoTbls.hs for details), so we need to pprDataExterns for info tables. cmm/PprCmm.hs: support CmmLabelDiffOff codeGen/CgInfoTbls.hs: no longer store absolute addresses in info tables, instead, we store offsets. Also, for vectored return points, emit the alternatives _after_ the vector table. This is to work around a limitation in Apple's as, which refuses to handle label differences where one label is at the end of a section. Emitting alternatives after vector info tables makes sure this never happens in GHC generated code. Case alternatives now require prototypes in hc code, though (see changes in PprC.hs, CLabel.hs). main/CmdLineOpts.lhs: Add a new option, -fPIC. main/DriverFlags.hs: Pass the correct options for PIC to gcc, depending on the platform. Only for powerpc for now. nativeGen/AsmCodeGen.hs: Many changes... Mac OS X-specific management of import stubs is no longer, it's now part of a general mechanism to handle such things for all platforms that need it (Darwin [both ppc and x86], Linux on ppc, and some platforms we don't support). Move cmmToCmm into its own monad which can accumulate a list of imported symbols. Make it call cmmMakeDynamicReference at the right places. nativeGen/MachCodeGen.hs: nativeGen/MachInstrs.hs: nativeGen/MachRegs.lhs: nativeGen/PprMach.hs: nativeGen/RegAllocInfo.hs: Too many changes to enumerate here, PowerPC specific. nativeGen/NCGMonad.hs: NatM still tracks imported symbols, as more labels can be created during code generation (float literals, jump tables; on some platforms all data access has to go through the dynamic linking mechanism). driver/mangler/ghc-asm.lprl: Mangle absolute addresses in info tables to offsets. Correctly pass through GCC-generated PIC for Mac OS X and powerpc linux. includes/Cmm.h: includes/InfoTables.h: includes/Storage.h: includes/mkDerivedConstants.c: rts/GC.c: rts/GCCompact.c: rts/HeapStackCheck.cmm: rts/Printer.c: rts/RetainerProfile.c: rts/Sanity.c: Adapt to the fact that info tables now contain offsets. rts/Linker.c: Mac-specific: change machoInitSymbolsWithoutUnderscore to support PIC.
* [project @ 2004-10-01 13:42:04 by simonpj]simonpj2004-10-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------ Simplify the treatment of newtypes Complete hi-boot file consistency checking ------------------------------------ In the representation of types, newtypes used to have a special constructor all to themselves, very like TyConApp, called NewTcApp. The trouble is that means we have to *know* when a newtype is a newtype, and in an hi-boot context we may not -- the data type might be declared as data T in the hi-boot file, but as newtype T = ... in the source file. In GHCi, which accumulates stuff from multiple compiles, this makes a difference. So I've nuked NewTcApp. Newtypes are represented using TyConApps again. This turned out to reduce the total amount of code, and simplify the Type data type, which is all to the good. This commit also fixes a few things in the hi-boot consistency checking stuff.
* [project @ 2004-10-01 09:49:14 by simonpj]simonpj2004-10-011-3/+12
| | | | Generate in the @size suffix for a stdcall symbol properly.
* [project @ 2004-09-30 10:35:15 by simonpj]simonpj2004-09-3012-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------ 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-09-17 08:25:25 by simonmar]simonmar2004-09-171-2/+2
| | | | Remove debugging trace that I left in when working on mk_switch.
* [project @ 2004-09-15 12:06:08 by simonmar]simonmar2004-09-151-6/+8
| | | | Oops, fix bugs in previous commit.
* [project @ 2004-09-15 11:45:24 by simonmar]simonmar2004-09-151-3/+40
| | | | | | | | | | | | | | Add a couple of cases to mk_switch to catch the case when we have a tag range that has a lot of default cases at either end, and we're not using a single switch. In situations like this we want to eliminate the default cases with an if-statement, before dealing with the rest of the branches, which might then be suitable for a switch. Also, ignore empty tag slots at either end of the range if there is no default case. This might work around a gcc 2.95 bug that we tickled with the code being generated before.
* [project @ 2004-09-10 14:53:44 by simonmar]simonmar2004-09-103-13/+13
| | | | | | | | | | | Fix problem that shows up when building stage2 on Windows: slots of a vector table that can never happen are normally filled with the RtsShouldNeverHappen label, which currently prints as "0". On systems with leading underscores on labels, such as Windows, this turns into "_0" which is reported as an undefined symbol. Having a label print as "0" is a real hack, so the solution is to do it properly. This commit does just that.
* [project @ 2004-08-20 12:21:03 by simonmar]simonmar2004-08-201-20/+5
| | | | | | | | | | | Simplify the "impossible branch" handling, and fix a bug in the process. CmmSwitch encodes the possibility of having impossible branches (the destinations are Maybe BlockId rather than just BlockId) so we don't need to encode impossible branches as dummy blocks containing a jump to an impossible location (currently 0). However, PprC and PprCmm weren't set up to cope with Nothings in a CmmSwitch, so this commit fixes that too.
* [project @ 2004-08-20 11:20:16 by simonmar]simonmar2004-08-201-2/+2
| | | | | Give literal string labels a _str suffix, to make it less likely that they'll clash with a symbol in scope in a C file.
* [project @ 2004-08-17 15:23:47 by simonpj]simonpj2004-08-173-10/+10
| | | | | | | | | | | | | | | | ------------------------------- Use merge-sort not quicksort Nuke quicksort altogether ------------------------------- Quicksort has O(n**2) behaviour worst case, and this occasionally bites. In particular, when compiling large files consisting only of static data, we get loads of top-level delarations -- and that led to more than half the total compile time being spent in the strongly connected component analysis for the occurrence analyser. Switching to merge sort completely solved the problem. I've nuked quicksort altogether to make sure this does not happen again.
* [project @ 2004-08-16 11:19:24 by simonmar]simonmar2004-08-161-1/+1
| | | | | | | | | | Define <arch>_TARGET_ARCH and <os>_TARGET_OS by default when CPP'ing. This avoids the main reason for needing to #include config.h into Haskell source, so most files that previously just #include "config.h" can now #if __GLASGOW_HASKELL__ < 603 #include "config.h" #endif
* [project @ 2004-08-13 13:26:37 by simonmar]simonmar2004-08-131-2/+2
| | | | sIZEOF_StgFunInfoExtra ==> sIZEOF_StgFunInfoExtraRev
* [project @ 2004-08-13 13:25:45 by simonmar]simonmar2004-08-131-2/+2
| | | | Fix minor merge-o
* [project @ 2004-08-13 13:04:50 by simonmar]simonmar2004-08-1326-4358/+6938
| | | | Merge backend-hacking-branch onto HEAD. Yay!
* [project @ 2004-08-10 09:02:36 by simonmar]simonmar2004-08-102-23/+14
| | | | | | | Fix problem with inline foreign-call changes yesterday. Foreign call args sometimes have to be modified using shimFCallArg - nowadays this is done at code generation time, whereas it used to be done at pretty-printing time.
* [project @ 2004-08-09 13:19:29 by simonmar]simonmar2004-08-091-24/+36
| | | | | | | | | | | | | | | | | | Allow case-of-unsafe-ccall to compile to straight-line code, like it used to. This has already been fixed on the backend-hacking-branch, but I'm doing it here so that it can be merged into the STABLE branch, where it will help to work around a bug. The bug is in CgExpr.lhs:primRetUnboxedTuple, which picks temporaries to assign the result of a ccall to. The Cg monad doesn't have a uniq supply (in the HEAD), so we always pick the same temporaries. This leads to clashes in complex function with multiple ccalls. Again, this is already fixed in the backend-hacking-branch. I don't see an easy fix for this bug. The compilation of case-of-unsafe-ccall doesn't suffer from this problem, and it will help work around some cases of the bug, so I'm going to merge this onto the STABLE branch after some testing.
* [project @ 2004-03-31 15:23:16 by simonmar]simonmar2004-03-312-5/+7
| | | | | | | ClosureInfo.might_be_a_function: this predicate wasn't taking into account abstract types, which might also hide functions underneath. Fixes broken compiler when compiled without -O.
* [project @ 2004-03-11 09:53:45 by simonmar]simonmar2004-03-111-2/+7
| | | | Add dependency on GHC.TopHandler if this is the main module.
* [project @ 2003-12-10 14:15:16 by simonmar]simonmar2003-12-101-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add accurate source location annotations to HsSyn ------------------------------------------------- Every syntactic entity in HsSyn is now annotated with a SrcSpan, which details the exact beginning and end points of that entity in the original source file. All honest compilers should do this, and it was about time GHC did the right thing. The most obvious benefit is that we now have much more accurate error messages; when running GHC inside emacs for example, the cursor will jump to the exact location of an error, not just a line somewhere nearby. We haven't put a huge amount of effort into making sure all the error messages are accurate yet, so there could be some tweaking still needed, although the majority of messages I've seen have been spot-on. Error messages now contain a column number in addition to the line number, eg. read001.hs:25:10: Variable not in scope: `+#' To get the full text span info, use the new option -ferror-spans. eg. read001.hs:25:10-11: Variable not in scope: `+#' I'm not sure whether we should do this by default. Emacs won't understand the new error format, for one thing. In a more elaborate editor setting (eg. Visual Studio), we can arrange to actually highlight the subexpression containing an error. Eventually this information will be used so we can find elements in the abstract syntax corresponding to text locations, for performing high-level editor functions (eg. "tell me the type of this expression I just highlighted"). Performance of the compiler doesn't seem to be adversely affected. Parsing is still quicker than in 6.0.1, for example. Implementation: This was an excrutiatingly painful change to make: both Simon P.J. and myself have been working on it for the last three weeks or so. The basic changes are: - a new datatype SrcSpan, which represents a beginning and end position in a source file. - To reduce the pain as much as possible, we also defined: data Located e = L SrcSpan e - Every datatype in HsSyn has an equivalent Located version. eg. type LHsExpr id = Located (HsExpr id) and pretty much everywhere we used to use HsExpr we now use LHsExpr. Believe me, we thought about this long and hard, and all the other options were worse :-) Additional changes/cleanups we made at the same time: - The abstract syntax for bindings is now less arcane. MonoBinds and HsBinds with their built-in list constructors have gone away, replaced by HsBindGroup and HsBind (see HsSyn/HsBinds.lhs). - The various HsSyn type synonyms have now gone away (eg. RdrNameHsExpr, RenamedHsExpr, and TypecheckedHsExpr are now HsExpr RdrName, HsExpr Name, and HsExpr Id respectively). - Utilities over HsSyn are now collected in a new module HsUtils. More stuff still needs to be moved in here. - MachChar now has a real Char instead of an Int. All GHC versions that can compile GHC now support 32-bit Chars, so this was a simplification.
* [project @ 2003-11-17 14:41:58 by simonmar]simonmar2003-11-171-6/+3
| | | | GC dead code.
* [project @ 2003-11-17 14:23:30 by simonmar]simonmar2003-11-172-6/+4
| | | | | | GC some dead code. In some places, I left useful-looking but currently unused definitions in place, surrounded by #ifdef UNUSED ... #endif.
* [project @ 2003-10-30 16:01:49 by simonpj]simonpj2003-10-302-6/+84
| | | | | | | | | | | This commit does a long-overdue tidy-up * Remove PprType (gets rid of one more bunch of hi-boot files) * Put pretty-printing for types in TypeRep * Make a specialised pretty-printer for Types, rather than converting to IfaceTypes and printing those
* [project @ 2003-10-09 11:58:39 by simonpj]simonpj2003-10-094-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------- GHC heart/lung transplant ------------------------- This major commit changes the way that GHC deals with importing types and functions defined in other modules, during renaming and typechecking. On the way I've changed or cleaned up numerous other things, including many that I probably fail to mention here. Major benefit: GHC should suck in many fewer interface files when compiling (esp with -O). (You can see this with -ddump-rn-stats.) It's also some 1500 lines of code shorter than before. ** So expect bugs! I can do a 3-stage bootstrap, and run ** the test suite, but you may be doing stuff I havn't tested. ** Don't update if you are relying on a working HEAD. In particular, (a) External Core and (b) GHCi are very little tested. But please, please DO test this version! ------------------------ Big things ------------------------ Interface files, version control, and importing declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * There is a totally new data type for stuff that lives in interface files: Original names IfaceType.IfaceExtName Types IfaceType.IfaceType Declarations (type,class,id) IfaceSyn.IfaceDecl Unfoldings IfaceSyn.IfaceExpr (Previously we used HsSyn for type/class decls, and UfExpr for unfoldings.) The new data types are in iface/IfaceType and iface/IfaceSyn. They are all instances of Binary, so they can be written into interface files. Previous engronkulation concering the binary instance of RdrName has gone away -- RdrName is not an instance of Binary any more. Nor does Binary.lhs need to know about the ``current module'' which it used to, which made it specialised to GHC. A good feature of this is that the type checker for source code doesn't need to worry about the possibility that we might be typechecking interface file stuff. Nor does it need to do renaming; we can typecheck direct from IfaceSyn, saving a whole pass (module TcIface) * Stuff from interface files is sucked in *lazily*, rather than being eagerly sucked in by the renamer. Instead, we use unsafeInterleaveIO to capture a thunk for the unfolding of an imported function (say). If that unfolding is every pulled on, TcIface will scramble over the unfolding, which may in turn pull in the interface files of things mentioned in the unfolding. The External Package State is held in a mutable variable so that it can be side-effected by this lazy-sucking-in process (which may happen way later, e.g. when the simplifier runs). In effect, the EPS is a kind of lazy memo table, filled in as we suck things in. Or you could think of it as a global symbol table, populated on demand. * This lazy sucking is very cool, but it can lead to truly awful bugs. The intent is that updates to the symbol table happen atomically, but very bad things happen if you read the variable for the table, and then force a thunk which updates the table. Updates can get lost that way. I regret this subtlety. One example of the way it showed up is that the top level of TidyPgm (which updates the global name cache) to be much more disciplined about those updates, since TidyPgm may itself force thunks which allocate new names. * Version numbering in interface files has changed completely, fixing one major bug with ghc --make. Previously, the version of A.f changed only if A.f's type and unfolding was textually different. That missed changes to things that A.f's unfolding mentions; which was fixed by eagerly sucking in all of those things, and listing them in the module's usage list. But that didn't work with --make, because they might have been already sucked in. Now, A.f's version changes if anything reachable from A.f (via interface files) changes. A module with unchanged source code needs recompiling only if the versions of any of its free variables changes. [This isn't quite right for dictionary functions and rules, which aren't mentioned explicitly in the source. There are extensive comments in module MkIface, where all version-handling stuff is done.] * We don't need equality on HsDecls any more (because they aren't used in interface files). Instead we have a specialised equality for IfaceSyn (eqIfDecl etc), which uses IfaceEq instead of Bool as its result type. See notes in IfaceSyn. * The horrid bit of the renamer that tried to predict what instance decls would be needed has gone entirely. Instead, the type checker simply sucks in whatever instance decls it needs, when it needs them. Easy! Similarly, no need for 'implicitModuleFVs' and 'implicitTemplateHaskellFVs' etc. Hooray! Types and type checking ~~~~~~~~~~~~~~~~~~~~~~~ * Kind-checking of types is far far tidier (new module TcHsTypes replaces the badly-named TcMonoType). Strangely, this was one of my original goals, because the kind check for types is the Right Place to do type splicing, but it just didn't fit there before. * There's a new representation for newtypes in TypeRep.lhs. Previously they were represented using "SourceTypes" which was a funny compromise. Now they have their own constructor in the Type datatype. SourceType has turned back into PredType, which is what it used to be. * Instance decl overlap checking done lazily. Consider instance C Int b instance C a Int These were rejected before as overlapping, because when seeking (C Int Int) one couldn't tell which to use. But there's no problem when seeking (C Bool Int); it can only be the second. So instead of checking for overlap when adding a new instance declaration, we check for overlap when looking up an Inst. If we find more than one matching instance, we see if any of the candidates dominates the others (in the sense of being a substitution instance of all the others); and only if not do we report an error. ------------------------ Medium things ------------------------ * The TcRn monad is generalised a bit further. It's now based on utils/IOEnv.lhs, the IO monad with an environment. The desugarer uses the monad too, so that anything it needs can get faulted in nicely. * Reduce the number of wired-in things; in particular Word and Integer are no longer wired in. The latter required HsLit.HsInteger to get a Type argument. The 'derivable type classes' data types (:+:, :*: etc) are not wired in any more either (see stuff about derivable type classes below). * The PersistentComilerState is now held in a mutable variable in the HscEnv. Previously (a) it was passed to and then returned by many top-level functions, which was painful; (b) it was invariably accompanied by the HscEnv. This change tidies up top-level plumbing without changing anything important. * Derivable type classes are treated much more like 'deriving' clauses. Previously, the Ids for the to/from functions lived inside the TyCon, but now the TyCon simply records their existence (with a simple boolean). Anyone who wants to use them must look them up in the environment. This in turn makes it easy to generate the to/from functions (done in types/Generics) using HsSyn (like TcGenDeriv for ordinary derivings) instead of CoreSyn, which in turn means that (a) we don't have to figure out all the type arguments etc; and (b) it'll be type-checked for us. Generally, the task of generating the code has become easier, which is good for Manuel, who wants to make it more sophisticated. * A Name now says what its "parent" is. For example, the parent of a data constructor is its type constructor; the parent of a class op is its class. This relationship corresponds exactly to the Avail data type; there may be other places we can exploit it. (I made the change so that version comparison in interface files would be a bit easier; but in fact it tided up other things here and there (see calls to Name.nameParent). For example, the declaration pool, of declararations read from interface files, but not yet used, is now keyed only by the 'main' name of the declaration, not the subordinate names. * New types OccEnv and OccSet, with the usual operations. OccNames can be efficiently compared, because they have uniques, thanks to the hashing implementation of FastStrings. * The GlobalRdrEnv is now keyed by OccName rather than RdrName. Not only does this halve the size of the env (because we don't need both qualified and unqualified versions in the env), but it's also more efficient because we can use a UniqFM instead of a FiniteMap. Consequential changes to Provenance, which has moved to RdrName. * External Core remains a bit of a hack, as it was before, done with a mixture of HsDecls (so that recursiveness and argument variance is still inferred), and IfaceExprs (for value declarations). It's not thoroughly tested. ------------------------ Minor things ------------------------ * DataCon fields dcWorkId, dcWrapId combined into a single field dcIds, that is explicit about whether the data con is a newtype or not. MkId.mkDataConWorkId and mkDataConWrapId are similarly combined into MkId.mkDataConIds * Choosing the boxing strategy is done for *source* type decls only, and hence is now in TcTyDecls, not DataCon. * WiredIn names are distinguished by their n_sort field, not by their location, which was rather strange * Define Maybes.mapCatMaybes :: (a -> Maybe b) -> [a] -> [b] and use it here and there * Much better pretty-printing of interface files (--show-iface) Many, many other small things. ------------------------ File changes ------------------------ * New iface/ subdirectory * Much of RnEnv has moved to iface/IfaceEnv * MkIface and BinIface have moved from main/ to iface/ * types/Variance has been absorbed into typecheck/TcTyDecls * RnHiFiles and RnIfaces have vanished entirely. Their work is done by iface/LoadIface * hsSyn/HsCore has gone, replaced by iface/IfaceSyn * typecheck/TcIfaceSig has gone, replaced by iface/TcIface * typecheck/TcMonoType has been renamed to typecheck/TcHsType * basicTypes/Var.hi-boot and basicTypes/Generics.hi-boot have gone altogether
* [project @ 2003-09-16 13:03:37 by simonmar]simonmar2003-09-161-1/+1
| | | | | | | | | | | | | Legacy Removal ~~~~~~~~~~~~~~ The following features have been consigned to the bit bucket: _ccall_ _casm_ ``....'' (lit-lits) the CCallable class the CReturnable class
* [project @ 2003-07-28 16:05:30 by simonmar]simonmar2003-07-282-79/+3
| | | | | | | | | | | 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-22 16:11:26 by simonmar]simonmar2003-07-221-4/+6
| | | | | Another cost-centre-restoring fix. Restoring the cost centre in an unboxed-tuple case alternative was using the wrong stack offset.
* [project @ 2003-07-21 11:01:06 by simonmar]simonmar2003-07-212-12/+16
| | | | | | | | 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-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-09 11:06:31 by simonpj]simonpj2003-07-091-3/+3
| | | | | | | | | | | | | | | | | -------------------------- Fix two External-Core bugs -------------------------- 1. An inadvertent "let x = ...x..." bug in TcRnDriver 2. Adjust the new -main-is story, so that the root module is called ":Main" instead of "$Main". This means that the z-encoded module name is "ZCMain" rather than "zdMain", which in keeps the External-Core lexer happy. And is more consistent generally. 3. Make the renamer happy to see definitions from modules other than the "home" one, when doing External Core. In the main module, there'll be a definition for ZCMain.main.
* [project @ 2003-07-02 19:41:20 by ross]ross2003-07-021-2/+0
| | | | import fix
* [project @ 2003-07-02 13:18:24 by simonpj]simonpj2003-07-023-14/+6
| | | | | | | | | | | | | | | | | | 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-027-715/+504
| | | | | | | | | | | | | | | | ------------------------ 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-06-23 11:46:06 by simonpj]simonpj2003-06-231-3/+3
| | | | Fix previous -main-is commit
* [project @ 2003-06-23 10:35:15 by simonpj]simonpj2003-06-231-7/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------- Dealing with 'main' ------------------- 1. In GHC 6.0, a module with no "module Main ... where" header elicited an error "main is not in scope" if 'main' is not defined. We don't want this behaviour in GHCi. This happened because the parser expanded the (absent) header to "module Main( main ) where", and the 'main' in the export list isn't. Solution: elaborate HsModule to record whether the 'module ..." header was given explicitly by the user or not. 2. Add a -main-is flag, and document it, so that you can have a 'main' function that is not Main.main. Summary of changes * The -main-is flag nominates what the main function is to be (see the documentation). No -main-is flag says that the main function is Main.main -main-is Foo.baz says that the main function is Foo.baz -main-is Foo says that the main function is Foo.main -main-is baz says that the main function is Main.baz Let's say you say -main-is Foo.baz * TcRnDriver injects the extra definition $Mian.main :: IO t $Main.main = baz in the module Foo. Note the naming, which is a bit different than before; previously the extra defn was for Main.$main. The RTS invokes zdMain_main_closure. * CodeGen injects an extra initialisation block into module Foo, thus stginit_zdMain { stginit_Foo } That ensures that the RTS can initialise stginit_zdMain.
* [project @ 2003-06-09 13:17:38 by matthewc]matthewc2003-06-091-11/+19
| | | | Update IA64 port to work with gcc 3.3.
* [project @ 2003-06-02 13:27:33 by simonpj]simonpj2003-06-022-3/+3
| | | | Prune imports
* [project @ 2003-05-19 11:33:06 by simonmar]simonmar2003-05-191-1/+1
| | | | | Eeek! intsToReverseBitmap was borked for bitmaps with more than wORD_SIZE_IN_BITS entries.
* [project @ 2003-05-14 09:13:52 by simonmar]simonmar2003-05-1412-152/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 @ 2003-03-03 12:43:31 by simonmar]simonmar2003-03-031-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A round of space-leak fixing. - re-instate zapping of the PersistentCompilerState at various points during the compilation cycle in HscMain. This affects one-shot compilation only, since in this mode the information collected in the PCS is not required after creating the final interface file. - Unravel the recursive dependency between MkIface and CoreTidy/CoreToStg. Previously the CafInfo for each binding was calculated by CoreToStg, and fed back into the IdInfo of the Ids generated by CoreTidy (an earlier pass). MkIface then took this IdInfo and the bindings from CoreTidy to generate the interface; but it couldn't do this until *after* CoreToStg, because the CafInfo hadn't been calculated yet. The result was that the CoreTidy output lived until after CoreToStg, and at the same time as the CorePrep and STG syntax, which is wasted space, not to mention the complexity and general ugliness in HscMain. So now we calculate CafInfo directly in CoreTidy. The downside is that we have to predict what CorePrep is going to do to the bindings so we can tell what will turn into a CAF later, but it's no worse than before (it turned out that we were doing this prediction before in CoreToStg anyhow). - The typechecker lazilly typechecks unfoldings. It turns out that this is a good idea from a performance perspective, but it also means that it must hang on to all the information it needs to do the typechecking. Previously this meant holding on to the whole of the typechecker's environment, which includes all sorts of stuff which isn't necessary to typecheck unfoldings. By paring down the environment captured by the lazy unfoldings, we can save quite a bit of space in the phases after typechecking.
* [project @ 2003-02-12 15:01:31 by simonpj]simonpj2003-02-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------- Big upheaval to the way that constructors are named ------------------------------------- This commit enshrines the new story for constructor names. We could never really get External Core to work nicely before, but now it does. The story is laid out in detail in the Commentary ghc/docs/comm/the-beast/data-types.html so I will not repeat it here. [Manuel: the commentary isn't being updated, apparently.] However, the net effect is that in Core and in External Core, contructors look like constructors, and the way things are printed is all consistent. It is a fairly pervasive change (which is why it has been so long postponed), but I hope the question is now finally closed. All the libraries compile etc, and I've run many tests, but doubtless there will be some dark corners.
* [project @ 2003-01-07 14:31:19 by simonmar]simonmar2003-01-072-12/+12
| | | | Update comments