script: Implement jsglue trap for runJobs()

Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
Delan Azabani 2025-07-25 15:51:53 +08:00
parent 554b2da1ad
commit cc5a4d9436
2 changed files with 15 additions and 3 deletions

6
Cargo.lock generated
View file

@ -5239,7 +5239,7 @@ dependencies = [
[[package]]
name = "mozjs"
version = "0.14.1"
source = "git+https://github.com/servo/mozjs#b23161580b082e1ccfa3273d94f43f6168aedc3d"
source = "git+https://github.com/servo/mozjs#4035b0c4e9e2df5cacc68c4b71e7375a48605902"
dependencies = [
"bindgen 0.71.1",
"cc",
@ -5250,8 +5250,8 @@ dependencies = [
[[package]]
name = "mozjs_sys"
version = "0.128.13-2"
source = "git+https://github.com/servo/mozjs#b23161580b082e1ccfa3273d94f43f6168aedc3d"
version = "0.128.13-3"
source = "git+https://github.com/servo/mozjs#4035b0c4e9e2df5cacc68c4b71e7375a48605902"
dependencies = [
"bindgen 0.71.1",
"cc",

View file

@ -87,6 +87,7 @@ use crate::task_source::SendableTaskSource;
static JOB_QUEUE_TRAPS: JobQueueTraps = JobQueueTraps {
getIncumbentGlobal: Some(get_incumbent_global),
enqueuePromiseJob: Some(enqueue_promise_job),
runJobs: Some(run_jobs),
empty: Some(empty),
pushNewInterruptQueue: Some(push_new_interrupt_queue),
popInterruptQueue: Some(pop_interrupt_queue),
@ -241,6 +242,17 @@ unsafe extern "C" fn get_incumbent_global(_: *const c_void, _: *mut RawJSContext
result
}
#[allow(unsafe_code)]
unsafe extern "C" fn run_jobs(microtask_queue: *const c_void, cx: *mut RawJSContext) {
let cx = JSContext::from_ptr(cx);
wrap_panic(&mut || {
let microtask_queue = &*(microtask_queue as *const MicrotaskQueue);
// TODO: run Promise- and User-variant Microtasks, and do #notify-about-rejected-promises.
// Those will require real `target_provider` and `globalscopes` values.
microtask_queue.checkpoint(cx, |_| None, vec![], CanGc::note());
});
}
#[allow(unsafe_code)]
unsafe extern "C" fn empty(extra: *const c_void) -> bool {
let mut result = false;