Skip to content

added more information on gc and rooting#212

Open
Narfinger wants to merge 9 commits intoservo:mainfrom
Narfinger:gc
Open

added more information on gc and rooting#212
Narfinger wants to merge 9 commits intoservo:mainfrom
Narfinger:gc

Conversation

@Narfinger
Copy link
Copy Markdown
Contributor

This adds more information on Gc and rooting.

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>
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger
Copy link
Copy Markdown
Contributor Author

Narfinger commented Mar 12, 2026

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).
If somebody could contribute a small section how to use the rooted1 macro that would also be awesome.

Copy link
Copy Markdown
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger
Copy link
Copy Markdown
Contributor Author

Ok github screwed up a bit so I hope I got all the suggestions in.
I can think about a bit more how to include the JSContext stuff.

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>
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger
Copy link
Copy Markdown
Contributor Author

Ok I added, hopefully, a better transition from rooting to CanGc and then to JSContext.

@Narfinger Narfinger marked this pull request as ready for review March 31, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants