Skip to content
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

Add safe GC rooting infrastructure #346

Open
jdm opened this issue Feb 19, 2023 · 6 comments · Fixed by #352
Open

Add safe GC rooting infrastructure #346

jdm opened this issue Feb 19, 2023 · 6 comments · Fixed by #352

Comments

@jdm
Copy link
Member

jdm commented Feb 19, 2023

#344 (comment) exposes an area where users of this crate currently need to build their own abstractions like RootedVec. Moving this into mozjs would allow creating safe HandleValueArray constructors. This would also require moving most of the tracing infrastructure into this crate, like the JSTraceable interface and RootedJSTraceableSet, and ensure that all runtimes have a trace hook that traces the known traceable set.

@jdm jdm mentioned this issue Feb 19, 2023
@sagudev
Copy link
Member

sagudev commented Feb 19, 2023

What role does script_plugin provider of unrooted_must_root lint plays on those types if any?

@jdm
Copy link
Member Author

jdm commented Feb 19, 2023

The script plugin is used for marking types that are only safe when used in a way that the GC can observe them. Ideally, types like JSVal and JSString and JSObject would be marked with it, but I suspect that requires further thought about supporting them correctly.

@Redfire75369
Copy link
Contributor

I am currently looking into taking the mozjs::rust::Trace trait and moving it to mozjs_sys (with re-exports for backwards compatibility). It seems pretty good so far.

RootedTraceableSet has been implemented, will be working on RootedVec soon enough.

@Redfire75369
Copy link
Contributor

Actually, I'm not too sure about how RootedVec should be implemented or designed, so I'll just make a PR first with the improved tracing infrastructure.

@sagudev
Copy link
Member

sagudev commented Nov 28, 2024

Not done in #352.

@sagudev sagudev reopened this Nov 28, 2024
@sagudev
Copy link
Member

sagudev commented Nov 28, 2024

We should write warning on HandleValueArray::from_rooted_slice that it expects rooted slice not slice of rooted elements.

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 a pull request may close this issue.

3 participants