3 ms·
No, I don't think they do. Given a function `foo` that is allocating an object "o" and returns it to the upper scope, how would you do "escape analysis" to det
by lerno 1y ago
No, I don't think they do.
Given a function `foo` that is allocating an object "o" and returns it to the upper scope, how would you do "escape analysis" to determine it should be freed and HOW it should be freed? What is the mechanism if you do not have RAII, ARC or GC?
- throwawaymaths 1y agoyou track how the variable is used in the compilation unit which should have a finite set of possibilities?
- lerno 1y agoThis is about tracking allocated memory, which is different. I know V claimed it could solve this with static analysis, but in practice it didn't work and had to fallback to a GC. This is true for all similar schemes, that they have something for easy for simple-to-track allocations, and then have to fallback on something generic. But even that is usually assuming that the language is somehow having a built-in notion of memory allocation and freeing.
- dnautics 1y agoIt should be possible in zig! Here's a proof of concept, I would guess that if V failed it was because they tried to do it at the language level. If you analyse intermediate representations the work is much, much easier. https://youtu.be/ZY_Z-aGbYm8?feature=shared https://youtu.be/ZY_Z-aGbYm8?feature=shared