wybe
wybe copied to clipboard
Implement escape analysis and use the results to turn heap allocations into stack allocations
The benefit is that stack allocations are very cheap, and reclaimed for free when the procedure exits. The cost is greater stack usage.
Greater heap usage?
Oops. Fixed.
It's worth reading Oxidizing OCaml: Locality for a nice discussion of a similar idea in the context of OCaml. Their approach requires locality (freedom from escape) to be declared, whereas this request is for locality to be (conservatively) inferred, which makes it easier to use (with 0 effort), but not certain for the programmer. A possible improvement would be to allow the programmer to declare that something should be allocated locally, and have the compiler warn or error if it won't be.