-
Notifications
You must be signed in to change notification settings - Fork 124
Expose ScriptEnvironmentPreparer to Rust #598
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
base: main
Are you sure you want to change the base?
Conversation
MOZ_ASSERT(JS_IsGlobalObject(global)); | ||
MOZ_ASSERT(!JS_IsExceptionPending(cx)); | ||
|
||
JSAutoRealm ar(cx, global); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like you're modelling it off of the jsshell version, but I intend to use this to replicate https://searchfox.org/mozilla-central/rev/fcc0cfc7f5b1df957ae29f6b2ccfeb6df47b6be8/xpcom/base/CycleCollectedJSRuntime.cpp#2177 . Since AutoEntryScript is a Servo Rust type, can we make this class implement a hook for Rust code to invoke the closure instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intend to use this to replicate https://searchfox.org/mozilla-central/rev/fcc0cfc7f5b1df957ae29f6b2ccfeb6df47b6be8/xpcom/base/CycleCollectedJSRuntime.cpp#2177
can you elaborate on this? i’m not sure i follow, did you have existing plans to set up a ScriptEnvironmentPreparer for Servo?
Since AutoEntryScript is a Servo Rust type, can we make this class implement a hook for Rust code to invoke the closure instead?
yeah, that could work. would the idea be that RustEnvironmentPreparer::invoke() just passes the closure to Servo, which would enter the AutoEntryScript and call the closure?
also, what do we do with uncaught exceptions? the jsshell uses a thing called AutoReportException, but i’m not sure what the Servo counterpart is for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate on this? i’m not sure i follow, did you have existing plans to set up a ScriptEnvironmentPreparer for Servo?
I didn't know it existed until this PR, but now I want to replicate the way Gecko uses it.
yeah, that could work. would the idea be that RustEnvironmentPreparer::invoke() just passes the closure to Servo, which would enter the AutoEntryScript and call the closure
Yes.
also, what do we do with uncaught exceptions? the jsshell uses a thing called AutoReportException, but i’m not sure what the Servo counterpart is for that.
We have code that calls report_pending_exception in various places right now. Gecko uses AutoJsApi, which is another thing I want to replicate.
Signed-off-by: Delan Azabani <[email protected]>
heads up: this is a lower priority for us now, since it only seems to be needed for handling uncaught exceptions in the debugger script (servo/servo#38331). |
That's fine. I suggest just calling report_pending_exception by hand. |
NOTE: do not merge until #597 lands