Changes between Version 26 and Version 27 of Commentary/Compiler/StackAreas
- Jun 6, 2008 4:19:16 PM (7 years ago)
v26 v27 87 87 === Laying out the stack === 88 88 89 A naive way to lay out the stack would be to give each variable its own stack slot for spilling, 89 A 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. 90 92 91 93 As 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.