Skip to content

Allow extracting the box out of a RootedTraceableBox.#739

Merged
jdm merged 4 commits into
servo:mainfrom
jdm:rooted-traceable-into-box
May 1, 2026
Merged

Allow extracting the box out of a RootedTraceableBox.#739
jdm merged 4 commits into
servo:mainfrom
jdm:rooted-traceable-into-box

Conversation

@jdm
Copy link
Copy Markdown
Member

@jdm jdm commented Apr 21, 2026

This method is important for making it easier to use typed arrays more safely in Servo. We can pass around RootedTraceableBox values into functions that return heap-allocated objects that need to store the inner Heap instead of the RootedTraceableBox.

Testing: Added unit test.
Servo PR: servo/servo#44464

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
@jdm jdm force-pushed the rooted-traceable-into-box branch from ff67f37 to c8259e1 Compare April 29, 2026 01:12
jdm added 2 commits April 30, 2026 12:41
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
@jdm jdm marked this pull request as ready for review April 30, 2026 17:02
@jdm
Copy link
Copy Markdown
Member Author

jdm commented Apr 30, 2026

b997fd3 is part of this because it's also needed for servo/servo#44464 for identical reasons as RootedTraceableBox::into_box.

@jdm jdm requested a review from sagudev April 30, 2026 18:12
Copy link
Copy Markdown
Member

@sagudev sagudev left a comment

Choose a reason for hiding this comment

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

LGTM


pub fn into_box(mut self) -> Box<T> {
self.cleanup()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should write doc comment here that T is not rooted anymore.

I think we currently do not mark such things as unsafe everytime, but eventually we should (except if we pass &NoGc and bound it's lifetime to return type).

Comment thread mozjs/src/gc/collections.rs
Comment thread mozjs/src/gc/root.rs
@jdm jdm enabled auto-merge May 1, 2026 13:33
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
@jdm jdm force-pushed the rooted-traceable-into-box branch from 9064bbd to 6652b61 Compare May 1, 2026 14:38
@jdm jdm added this pull request to the merge queue May 1, 2026
Merged via the queue into servo:main with commit d083133 May 1, 2026
45 checks passed
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.

2 participants