Changes between Version 2 and Version 3 of Commentary/Compiler/Demand

Aug 28, 2012 11:25:37 AM (5 years ago)



  • Commentary/Compiler/Demand

    v2 v3  
    1717== Relevant compiler parts ==
    19 [TODO]
     19Multiple parts of GHC are sensitive to changes in the nature of demand signatures and results of the demand analysis, which might cause unexpected errors when hacking into demands. Below, some of the demand-sensitive compiler parts are enumerated with indications, which bits of the demand information are actually used.
     21  * `compiler/basicTypes/Demand.lhs` -- contains all information about demands and operations on them, as well as about serialization/deserialization of demand signatures. This module is supposed to be changes whenever the demand nature should be enhanced;
     23  * `compiler/basicTypes/Id.lhs` -- implementation of identifiers contains a number of utility functions to check/set demand annotations of binders. All of them are just delegating to appropriate functions/fields of the `IdInfo` record;
     25  * `compiler/basicTypes/IdInfo.lhs` -- `IdInfo` record contains all information about demand and strictness annotations of an identifier. `strictnessInfo` contains a representation of an abstract two-point demand transformer of a binder, considered as a reference to a value. `demandInfo` indicates, which demand is put to the identifier, which is a function parameter, if the function is called in a strict/used context. `seq*`-functions are invoked to avoid memory leaks caused by transforming new ASTs by each of the compiler passes (i.e., no thunks pointing to the parts of the processed trees are left).
     27  * `compiler/basicTypes/MkId.lhs` -- A machinery, responsible for generation of worker-wrappers makes use of demands. For instance, when a signature for a worker is generated, the following strictness signature is created:
     30  wkr_sig = mkStrictSig (mkTopDmdType (replicate wkr_arity top) cpr_info)
     33  In words, a non-bottoming demand type with `N` lazy/used arguments (`top`) is created for a worker, where `N` is just a worker's pre-computed arity. Also, particular demands are used when creating signatures for dictionary selectors (see `mkDictSelId`).
     35  * `compiler/prelude/primops.txt.pp` -- this file defines demand signatures for primitive operations, which are inserted by `cpp` pass on the module `compiler/basicTypes/MkId.lhs`;
     37  * `compiler/coreSyn/CoreArity.lhs` -- demand signatures are used in order to compute the unfolding info of a function: bottoming functions should no be unfolded. See `exprBotStrictness_maybe` and `arityType`.
     39  * `compiler/coreSyn/CoreLint.lhs` -- the checks are performed (in `lintSingleBinding`):
     40    * whether arity and demand type are consistent (only if demand analysis already happened);
     41    * if the binder is top-level or recursive, it's not demanded (i.e., its demand is not strict).
     43  * `compiler/coreSyn/CorePrep.lhs` -- strictness signatures are examining before converting expression to A-normal form.
     45  * `compiler/coreSyn/MkCore.lhs` -- a bottoming strictness signature created for `error`-like functions (see `pc_bottoming_Id`).
     47  * `compiler/coreSyn/PprCore.lhs` -- standard pretty-printing machinery, should be modified to change PP of demands.
     49  * `compiler/iface/IfaceSyn.lhs`  -- serialization, grep for `HsStrictness` constructors.
     51  * `compiler/iface/MkIface.lhs`  -- a client of `IfaceSyn`, see usages of `HsStrictness`.
     53  * `compiler/iface/TcIface.lhs` -- TODO