summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmCPSGen.hs
Commit message (Collapse)AuthorAgeFilesLines
* Merge in new code generator branch.Simon Marlow2011-01-241-517/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | This changes the new code generator to make use of the Hoopl package for dataflow analysis. Hoopl is a new boot package, and is maintained in a separate upstream git repository (as usual, GHC has its own lagging darcs mirror in http://darcs.haskell.org/packages/hoopl). During this merge I squashed recent history into one patch. I tried to rebase, but the history had some internal conflicts of its own which made rebase extremely confusing, so I gave up. The history I squashed was: - Update new codegen to work with latest Hoopl - Add some notes on new code gen to cmm-notes - Enable Hoopl lag package. - Add SPJ note to cmm-notes - Improve GC calls on new code generator. Work in this branch was done by: - Milan Straka <fox@ucw.cz> - John Dias <dias@cs.tufts.edu> - David Terei <davidterei@gmail.com> Edward Z. Yang <ezyang@mit.edu> merged in further changes from GHC HEAD and fixed a few bugs.
* Implement stack chunks and separate TSO/STACK objectsSimon Marlow2010-12-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes two changes to the way stacks are managed: 1. The stack is now stored in a separate object from the TSO. This means that it is easier to replace the stack object for a thread when the stack overflows or underflows; we don't have to leave behind the old TSO as an indirection any more. Consequently, we can remove ThreadRelocated and deRefTSO(), which were a pain. This is obviously the right thing, but the last time I tried to do it it made performance worse. This time I seem to have cracked it. 2. Stacks are now represented as a chain of chunks, rather than a single monolithic object. The big advantage here is that individual chunks are marked clean or dirty according to whether they contain pointers to the young generation, and the GC can avoid traversing clean stack chunks during a young-generation collection. This means that programs with deep stacks will see a big saving in GC overhead when using the default GC settings. A secondary advantage is that there is much less copying involved as the stack grows. Programs that quickly grow a deep stack will see big improvements. In some ways the implementation is simpler, as nothing special needs to be done to reclaim stack as the stack shrinks (the GC just recovers the dead stack chunks). On the other hand, we have to manage stack underflow between chunks, so there's a new stack frame (UNDERFLOW_FRAME), and we now have separate TSO and STACK objects. The total amount of code is probably about the same as before. There are new RTS flags: -ki<size> Sets the initial thread stack size (default 1k) Egs: -ki4k -ki2m -kc<size> Sets the stack chunk size (default 32k) -kb<size> Sets the stack chunk buffer size (default 1k) -ki was previously called just -k, and the old name is still accepted for backwards compatibility. These new options are documented.
* Interruptible FFI calls with pthread_kill and CancelSynchronousIO. v4Edward Z. Yang2010-09-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | This is patch that adds support for interruptible FFI calls in the form of a new foreign import keyword 'interruptible', which can be used instead of 'safe' or 'unsafe'. Interruptible FFI calls act like safe FFI calls, except that the worker thread they run on may be interrupted. Internally, it replaces BlockedOnCCall_NoUnblockEx with BlockedOnCCall_Interruptible, and changes the behavior of the RTS to not modify the TSO_ flags on the event of an FFI call from a thread that was interruptible. It also modifies the bytecode format for foreign call, adding an extra Word16 to indicate interruptibility. The semantics of interruption vary from platform to platform, but the intent is that any blocking system calls are aborted with an error code. This is most useful for making function calls to system library functions that support interrupting. There is no support for pre-Vista Windows. There is a partner testsuite patch which adds several tests for this functionality.
* * Refactor CLabel.RtsLabel to CLabel.CmmLabelBen.Lippmeier@anu.edu.au2009-11-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type of the CmmLabel ctor is now CmmLabel :: PackageId -> FastString -> CmmLabelInfo -> CLabel - When you construct a CmmLabel you have to explicitly say what package it is in. Many of these will just use rtsPackageId, but I've left it this way to remind people not to pretend labels are in the RTS package when they're not. - When parsing a Cmm file, labels that are not defined in the current file are assumed to be in the RTS package. Labels imported like import label are assumed to be in a generic "foreign" package, which is different from the current one. Labels imported like import "package-name" label are marked as coming from the named package. This last one is needed for the integer-gmp library as we want to refer to labels that are not in the same compilation unit, but are in the same non-rts package. This should help remove the nasty #ifdef __PIC__ stuff from integer-gmp/cbits/gmp-wrappers.cmm
* Merge RtsLabelInfo.Rts* with RtsLabelInfo.Rts*FSBen.Lippmeier@anu.edu.au2009-10-181-2/+2
|
* Remove GHC's haskell98 dependencyIan Lynagh2009-07-241-1/+1
|
* Remove unused importsIan Lynagh2009-07-071-1/+0
|
* Fix warnings in CmmCPSGenIan Lynagh2008-12-291-13/+23
|
* Merging in the new codegen branchdias@eecs.harvard.edu2008-08-141-33/+32
| | | | | | | | | | | | | | | | | | This merge does not turn on the new codegen (which only compiles a select few programs at this point), but it does introduce some changes to the old code generator. The high bits: 1. The Rep Swamp patch is finally here. The highlight is that the representation of types at the machine level has changed. Consequently, this patch contains updates across several back ends. 2. The new Stg -> Cmm path is here, although it appears to have a fair number of bugs lurking. 3. Many improvements along the CmmCPSZ path, including: o stack layout o some code for infotables, half of which is right and half wrong o proc-point splitting
* Fix Haddock errors.Thomas Schilling2008-07-201-7/+7
|
* Replacing copyins and copyouts with data-movement instructionsdias@eecs.harvard.edu2008-05-291-0/+1
| | | | | | | | | | | | | | o Moved BlockId stuff to a new file to avoid module recursion o Defined stack areas for parameter-passing locations and spill slots o Part way through replacing copy in and copy out nodes - added movement instructions for stack pointer - added movement instructions for call and return parameters (but not with the proper calling conventions) o Inserting spills and reloads for proc points is now procpoint-aware (it was relying on the presence of a CopyIn node as a proxy for procpoint knowledge) o Changed ZipDataflow to expect AGraphs (instead of being polymorphic in the type of graph)
* replace Cmm 'hint' with 'kind'Norman Ramsey2008-05-031-9/+9
| | | | | | C-- no longer has 'hints'; to guide parameter passing, it has 'kinds'. Renamed type constructor, data constructor, and record fields accordingly
* (F)SLIT -> (f)sLit in CmmCPSGenIan Lynagh2008-04-121-4/+2
|
* Don't import FastString in HsVersions.hIan Lynagh2008-03-291-0/+1
| | | | Modules that need it import it themselves instead.
* change CmmActual, CmmFormal to use a data CmmHinted rather than tuple (#1405)Isaac Dupree2008-01-041-9/+9
| | | | | | | This allows the instance of UserOfLocalRegs to be within Haskell98, and IMHO makes the code a little cleaner generally. This is one small (though tedious) step towards making GHC's code more portable...
* a good deal of salutory renamingNorman Ramsey2007-09-071-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've renamed a number of type and data constructors within Cmm so that the names used in the compiler may more closely reflect the C-- specification 2.1. I've done a bit of other renaming as well. Highlights: CmmFormal and CmmActual now bear a CmmKind (which for now is a MachHint as before) CmmFormals = [CmmFormal] and CmmActuals = [CmmActual] suitable changes have been made to both code and nonterminals in the Cmm parser (which is as yet untested) For reasons I don't understand, parts of the code generator use a sequence of 'formal parameters' with no C-- kinds. For these we now have the types type CmmFormalWithoutKind = LocalReg type CmmFormalsWithoutKinds = [CmmFormalWithoutKind] A great many appearances of (Tau, MachHint) have been simplified to the appropriate CmmFormal or CmmActual, though I'm sure there are more opportunities. Kind and its data constructors are now renamed to data GCKind = GCKindPtr | GCKindNonPtr to avoid confusion with the Kind used in the type checker and with CmmKind. Finally, in a somewhat unrelated bit (and in honor of Simon PJ, who thought of the name), the Whalley/Davidson 'transaction limit' is now called 'OptimizationFuel' with the net effect that there are no longer two unrelated uses of the abbreviation 'tx'.
* change of representation for GenCmm, GenCmmTop, CmmProcNorman Ramsey2007-09-051-1/+3
| | | | | | | | | The type parameter to a C-- procedure now represents a control-flow graph, not a single instruction. The newtype ListGraph preserves the current representation while enabling other representations and a sensible way of prettyprinting. Except for a few changes in the prettyprinter the new compiler binary should be bit-for-bit identical to the old.
* Fix CodingStyle#Warnings URLsIan Lynagh2007-09-041-1/+1
|
* Use OPTIONS rather than OPTIONS_GHC for pragmasIan Lynagh2007-09-031-2/+2
| | | | | | | Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
* Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modulesIan Lynagh2007-09-011-0/+7
|
* put CmmReturnInfo into a CmmCall (and related types)Norman Ramsey2007-08-201-6/+8
|
* Rename a constructor CmmForeignCall to CmmCallee, and tidy Cmm codesimonpj@microsoft.com2007-08-091-5/+5
| | | | | | This patch should have no effect; it's mainly comments, layout, plus this contructor name change.
* Fixes for the unreg buildIan Lynagh2007-07-181-2/+3
| | | | | | | * Fix code output order when printing C so things are defined before they are used. * Generate _ret rather than _entry functions for INFO_TABLE_RET. * Use "ASSIGN_BaseReg" rather than "BaseReg =".
* Factor 'callerSaveVolatileRegs' out of the NCG and into CgUtilMichael D. Adams2007-07-171-7/+0
| | | | | This is needed because CgForeign and parts of the CPS pass now use 'callerSaveVolatileRegs' and not all platforms have access to the NCG.
* Removed 'allow_header_set' argument from 'pack_continuation'.Michael D. Adams2007-07-151-12/+6
| | | | | | | Because branches might now go to continuations and become calls to continuations, 'allow_header_set' isn't always correct. Removing that parameter makes the conservative approximation. A better approximation might save one memory store is some cases.
* Fixed conditional branches to proc pointsMichael D. Adams2007-07-151-26/+40
| | | | These could occur due to GC checks.
* Fixed CPS to account for info tables not being next to codeMichael D. Adams2007-07-151-1/+2
|
* Fix the CPS pass to pack the continuation with correct label form.Michael D. Adams2007-07-141-1/+1
| | | | It was using the return point label before; now it uses the info label.
* Eliminated use of 'fromJust' from the CPS passMichael D. Adams2007-07-051-2/+1
|
* Fixed a bug in the CPS passMichael D. Adams2007-07-051-1/+1
|
* Added support for GC block declaration to the Cmm syntaxMichael D. Adams2007-07-051-19/+8
|
* Added support for update frames to the CPS passMichael D. Adams2007-07-031-34/+63
| | | | (This required a bit of refactoring of CmmInfo.)
* Moved 'continuationToProc' into a separate file, 'CmmCPSGen.hs'.Michael D. Adams2007-07-031-0/+475