On 10-12-16 09:30 AM, Rafael Ávila de Espíndola wrote:

But why do we restrict that mutable non-GC data cannot point to GC? An
optimization so that the garbage collector only has to look at the GC
layer?

To ensure that the division between GC and non-GC has meaning. The cycle must be broken somewhere!

GC memory can point to non-GC. If non-GC could, in turn, point to GC, then it would be possible to form a reference cycle with GC memory: non-GC memory could wind up owning itself. Meaning: destruction order would become non-deterministic.

I think. Possibly we the determination of non-GC-ness of mutable memory (involving inspection of the transitive closure of its structure) could be refined in such a way as to differentiate the two. But with the current non-GC-ness definition ("no mutable boxes holding recursive tags") it won't work. We'd need to ... I guess be able to prove that the GC-memory subgraphs within a non-GC type do not permit formation of cycles between themselves. A vector of cyclic lists is itself acyclic, say; so long as they're not cyclic lists of vectors of cyclic lists :)

Seems potentially harder to formalize. If you're really interested in studying the problem though, don't let me stop you! A clearer or more precise / useful rule than the existing one is plausible.

-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to