wybe icon indicating copy to clipboard operation
wybe copied to clipboard

Implement escape analysis and use the results to turn heap allocations into stack allocations

Open pschachte opened this issue 2 years ago • 3 comments

The benefit is that stack allocations are very cheap, and reclaimed for free when the procedure exits. The cost is greater stack usage.

pschachte avatar Sep 27 '22 11:09 pschachte

Greater heap usage?

jimbxb avatar Sep 27 '22 11:09 jimbxb

Oops. Fixed.

pschachte avatar Sep 27 '22 11:09 pschachte

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.

pschachte avatar Aug 02 '23 06:08 pschachte