-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support rooting arbitrary types #535
Conversation
116326d
to
2e43458
Compare
❤️
Where exactly is this used, I cannot seems to find any.
Can we somehow unify unsafe impl<T: Traceable> TraceableTrace for T {
unsafe fn do_trace(&mut self, trc: *mut JSTracer) {
<Self as Traceable>::trace(self, trc)
}
} Also we definitely want to test rooting of arbitrary types |
The Drop implementation for RootedGuard.
I've tried a bunch of different blanket impls like this but the compiler always complains that foreign traits have to be implemented on local types or T needs to be a type variable for a local type. Maybe it would be possible if Traceable and TraceableTrace were defined in the same crate? |
Also that particular blanket impls leads to conflicts with duplicate RootKind implementations, because of another blanket impl that involves TraceableTrace. |
I would consider that as a consumer, I am asking is there any type that its impl actually returns None.
Yes I think that would be needed.
I think the problem is that we impl Traceable for some RootKind types, maybe we should remove them and start using TraceableTrace as main tracing trait (Traceable would only exists for easier impl of Tracing on custom types). |
No, it will need to go the other way, others should impl TraceableTrace and then we add just few additional impl for Traceable (those who have RootKind). |
Right now, no. But it enables rooting arbitrary types in Servo without wrapping them in an Option. |
adc60e7
to
370d001
Compare
I moved Traceable to mozjs-sys and was able to remove the duplication between TraceableTrace (now renamed to Rootable) and Traceable. I'm really pleased with how easy it is to make rooted! support arbitrary Rust types now! |
Not exactly what I had in mind, but I think it's better this way! |
@sagudev Have you reviewed these changes but forgotten to mark them approved? |
I my mind I considered it OK, but companion PR does not work (might be sccache problem). Given the current state of mozjs being ahead of servo we should wait with landing this until stuff clears out. |
Got it! |
We can rebase this and companion PR and hope for the best. |
3162529
to
c5ded3c
Compare
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
…rown annotations. Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Josh Matthews <[email protected]>
c5ded3c
to
2f26a0e
Compare
These changes support servo/servo#34194 by:
Rooted[Guard]<T>
where T is annotated withmust_root
The GCMethods trait was being used in two contexts (
Rooted<T>
andHeap<T>
) but the barrier operation is only relevant forHeap<T>
. By splitting them out, we avoid the need to implement unused methods that make reviewers nervous.