Changes between Version 7 and Version 8 of Commentary/Compiler/StrictnessAnalysis


Ignore:
Timestamp:
Feb 4, 2007 8:50:43 PM (8 years ago)
Author:
kirsten
Comment:

some sanity checking

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/StrictnessAnalysis

    v7 v8  
    11[ Up: [wiki:Commentary/Compiler] ] 
     2 
     3= General overview = 
     4 
     5GHC's approach to strictness analysis is that of "demand analysis", a backwards analysis in which strictness analysis and absence analysis are done in a single pass. In the future, analysis to perform unboxing, as well as other analyses, may be implemented within this framework as well. 
    26 
    37= IMPORTANT NOTE = 
    48 
    5 This commentary describes code that is not checked in to the HEAD yet. 
     9The rest of this commentary describes code that is not checked in to the HEAD yet. 
    610 
    7 = The strictness analyzer = 
     11= The demand analyzer = 
    812 
    9 Most of the strictness analyzer lives in two files: 
     13Most of the demand analyzer lives in two files: 
    1014 
    11  * [[GhcFile(compiler/basicTypes/NewDemand.lhs)]] (defines the datatypes used by the strictness analyzer, and some functions on them) 
    12  * [[GhcFile(compiler/stranal/DmdAnal.lhs)]] (the strictness analyzer itself) 
     15 * [[GhcFile(compiler/basicTypes/NewDemand.lhs)]] (defines the datatypes used by the demand analyzer, and some functions on them) 
     16 * [[GhcFile(compiler/stranal/DmdAnal.lhs)]] (the demand analyzer itself) 
    1317 
    14 The strictness analyzer does demand analysis, absence analysis, and box-demand analysis in a single pass. (!ToDo: explain what these are.) 
     18The demand analyzer does strictness analysis, absence analysis, and box-demand analysis in a single pass. (!ToDo: explain what these are.) 
    1519 
    16 In [[GhcFile(compiler/stranal/DmdAnal.lhs)]], {{{dmdAnal}}} is the function that performs strictness analysis on an expression. It has the following type: 
     20In [[GhcFile(compiler/stranal/DmdAnal.lhs)]], {{{dmdAnal}}} is the function that performs demand analysis on an expression. It has the following type: 
    1721{{{ 
    1822dmdAnal :: SigEnv -> Demand-> CoreExpr -> (DmdType, CoreExpr) 
    1923}}} 
    20 The first argument is an environment mapping variables onto demand signatures. (!ToDo: explain more.) The second argument is the demand that's being placed on the expression being analyzed, which was determined from the context already. The third argument is the expression being analyzed. {{{dmdAnal}}} returns a pair of a new expression (possibly with strictness information added to any [wiki:Commentary/Compiler/NameType Ids] in it), and a {{{DmdType}}}. 
     24The first argument is an environment mapping variables onto demand signatures. (!ToDo: explain more.) The second argument is the demand that's being placed on the expression being analyzed, which was determined from the context already. The third argument is the expression being analyzed. {{{dmdAnal}}} returns a pair of a new expression (possibly with demand information added to any [wiki:Commentary/Compiler/NameType Ids] in it), and a {{{DmdType}}}. 
    2125 
    2226== Important datatypes == 
     
    8791             -> DmdType          
    8892}}} 
    89 Strictness analysis is implemented as a backwards analysis, so {{{dmdTransform}}} takes the demand on a function's result (which was inferred based on how the function's result is used) and uses that to compute the demand type of this particular occurrence of the function itself. 
     93Demand analysis is implemented as a backwards analysis, so {{{dmdTransform}}} takes the demand on a function's result (which was inferred based on how the function's result is used) and uses that to compute the demand type of this particular occurrence of the function itself. 
    9094 
    9195{{{dmdTransform}}} has four cases, depending on whether the function being analyzed is a [wiki:Commentary/Compiler/EntityTypes data constructor] worker, an imported (global) function, a local {{{let}}}-bound function, or "anything else" (e.g., a local lambda-bound function).