added more information on gc and rooting#212
Conversation
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
src/design-documentation/script.md
Outdated
| ```rust | ||
| #[dom_object] | ||
| struct Kittens { | ||
| children: Vec<Cat> |
There was a problem hiding this comment.
I think it would be a stronger example if Cat was also a dom object, and you would use not Vec but Vec<Dom>, or even RefCell<Vec<Dom<Cat>>>.
There was a problem hiding this comment.
I agree making it a Vec<Dom>.
I don't know about RefCell though. There is a whole other section about borrow checking and RefCell which explains this very well.. I am going to link to that.
src/design-documentation/script.md
Outdated
| # Script | ||
|
|
||
| Servo is unique in that it uses garbage collection for some things that are non obvious. For example, every dom object | ||
| (a struct with `#[dom_object])` on it is controlled by spidermonkeys garbage collector. Extra care is to be taken when interacting with this. While the garbage collector is complicated and has multiple modes we will assume for now the following. |
There was a problem hiding this comment.
added that this is what the document is about.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
|
Thanks for the comments! Currently I can't look at the formatting and how it looks in compiled form that is why it is in draft mode (and so other people can check the correctness). |
jdm
left a comment
There was a problem hiding this comment.
In-progress review because I need to think more about this, and also sleep. We jump from a very simplistic view of the GC (it can happen anywhere! at any time!) to suddenly passing around a mutable pointer to the context and talking about unrooted values. I think we probably want to introduce the idea of &mut JSContext much earlier in this documentation, possibly in the first example.
Co-authored-by: Josh Matthews <josh@joshmatthews.net> Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
|
Ok github screwed up a bit so I hope I got all the suggestions in. But I feel like it might not make sense to have it at the start. The start should be imho about why we need Gc anyway, What the rooted types are and how crown fits in all this. Then (probably before performance subsection) we can introduce JSContext. Something like: "But Gc actually only runs when we do specific spidermonkey apis and having CanGC everywhere is hazardous". |
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This adds more information on Gc and rooting.