4 ms·
I may be making a causal inference based on a correlation. What I had read about the compile time guarantees in Rust indicated that escape analysis was being u
by hinkley 11y ago
I may be making a causal inference based on a correlation. What I had read about the compile time guarantees in Rust indicated that escape analysis was being used to implement them, but I don't know if I read that or assumed.
I hadn't encountered Cyclone, but reading through a paper about it now, and it sounds a lot like reading about how Java uses escape analysis with its generational garbage collection to decide where to allocate objects. In fact in 8 goes a lot farther, and it can eliminate monitors, memory fences, and copy constructors that have no observable side effects.
Of course if Java ever conservatively wrong (retaining a dead allocation), the GC will take care of it later. In a language without a collector you have to be right in both directions.
- pcwalton 11y agoEscape analysis uses somewhat similar machinery in that it cares about the scopes in which variables are used, but the similarity pretty much ends there. Lifetimes, by contrast, are a type system feature. The closest thing to lifetimes in terms of implementation is actually generics (which makes sense, because lifetimes are just another kind of generic type parameter).