ace
ace copied to clipboard
Escape analysis
Escape analysis
Goal: Implement escape analysis in order to avoid unnecessary heap allocations.
After translation, before gen phase, add a phase to annotate heap-exprs.
Escape phase
- Build a usage graph of exprs.
- Find all exprs that have usage links to return statements or towards heap-marked exprs.
- For any tuples that link to return statements, mark them as heap.
- Goto 2 until no more exprs are marked.
During gen phase, pay attention to heap-marks on tuples.