Skip to content

script: Init and pass down &mut JSContext in script-related threads#41692

Merged
jdm merged 2 commits intoservo:mainfrom
sagudev:enter-cx
Jan 6, 2026
Merged

script: Init and pass down &mut JSContext in script-related threads#41692
jdm merged 2 commits intoservo:mainfrom
sagudev:enter-cx

Conversation

@sagudev
Copy link
Copy Markdown
Member

@sagudev sagudev commented Jan 5, 2026

  1. removed ScriptThread::get_safe_cx in favor of Runtime::cx (this intentionally shadows RustRuntime::cx, which is not really safe with all other stuff that happen in servo).
  2. passed down cx from ScriptThread::new to accommodate those changes (we also need to pass cx for some other stuff).
  3. we create JSContext in workers/worklets, so we can pass all the way down to
    CommonScriptMsg::Task(_, task, _, _) => task.run_box(),
    (so we can get &mut JSContext in tasks).

So with this PR, we prepared all entry points of JSContext (or other should actually be reentering via SM callback or passed down from the root one in the thread).

Testing: No changes just safety, but it should be covered by WPT
Part of #40600

@sagudev sagudev requested a review from gterzian as a code owner January 5, 2026 18:54
@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Jan 5, 2026
@sagudev sagudev requested review from jdm and removed request for gterzian January 5, 2026 18:54
t
Signed-off-by: sagudev <[email protected]>
@servo-highfive servo-highfive removed the S-needs-rebase There are merge conflict errors. label Jan 5, 2026
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jan 6, 2026
@jdm jdm added this pull request to the merge queue Jan 6, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 6, 2026
Merged via the queue into servo:main with commit 38306ea Jan 6, 2026
29 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 6, 2026
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