Changes between Version 26 and Version 27 of Commentary/Compiler/StackAreas


Ignore:
Timestamp:
Jun 6, 2008 4:19:16 PM (7 years ago)
Author:
dias
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/StackAreas

    v26 v27  
    8787=== Laying out the stack === 
    8888 
    89 A naive way to lay out the stack would be to give each variable its own stack slot for spilling,  
     89A naive approach to laying out the stack would be to give each variable its own stack slot for spilling, and allocate only the ends of the stack frame for parameter-passing areas. But this approach misses two important opportunities for optimization: 
     90 * Stack slots can be reused 
     91 * If a function returns a variable on the stack, we might be able to use the return location as the variable's spill slot. 
    9092 
    9193As it turns out, it is quite common in GHC that the first definition of a variable comes when its value is returned from a function call. If the value is returned on the stack, then an important optimization is to avoid copying that value to some other local location on the stack. How is that achieved? By making sure the location where the value is returned is defined as its spill slot.