Still chewing on this. Two questions below and one preliminary thought
below.

On Wed, Jul 10, 2013 at 11:32:08AM -0700, Patrick Walton wrote:
> This does mean that we need to make sure that all contents of `@mut`
> are Freeze; otherwise, we won't trip the barrier.

This seems stricter than necessary. You don't want unsafe mutation a
la Cell, but `@mut` should be ok.

> For generational GC, we must ensure that objects in the nursery
> pointed to by the tenured generation are either added to a remembered
> set or tenured. This is harder in Rust because we have to know both
> the generation of the referrer and the referent simultaneously. I
> believe that conservatively tenuring all objects that are mutated
> would be overconservative and defeat much of the purpose of GGC.

I don't get this. My understanding of how GGC works is that whenever a
tenured object is mutated, you flag it into a set. Then when you scan
the nursery, you scan only this set to uncover new roots. This
requires a write barrier. As you explained above, write barriers are
fairly straightforward with `@mut`, but quite challenging if you
replace `@mut` with Cell.

Preliminary thought:

I think we should either replace `@mut` with `Cell` or remove
`Cell`. Near as I can tell, `Cell` today exists primarily to
work-around limitations that all have better solutions in the works.

Moving from `@mut` to `Cell` is a more flexible and orthogonal system,
in that you can define the granularity of the write barriers and you
have have `Gc<Cell<T>>` and `Rc<Cell<T>>` rather than each kind of
opinter requiring a `Foo` and `FooMut` variant, all of which repeat
basically the same logic.

However, moving from `@mut` to `Cell` does seem to rule out write
barriers, and hence will limit the ability to write maximally
efficient garbage collectors. This may be ok, but it's definitely the
kind of decision you want to make with your eyes open, so I'm glad you
pointed this out!




Niko

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

Reply via email to