. sort variables by the alignment they need
. store largest variables first
- automatically aligns all the variables
- does not require padding
. store smallest variables first
- requires more space (padding)
- for large stack frame makes more variables accessible with small offsets
While allocating memory to the variables, sort variables by the alignment they need. You may:
. store largest variables first: It automatically aligns all the variables and does not require padding since the next variable's memory allocation starts at the end of that of the earlier variable
. store smallest variables first: It requires more space (padding) since you have to accommodate for the biggest possible length of any variable data structure. The advantage is that for large stack frame, more variables become accessible within small offsets
|