Prevent moving CanGc values between threads/tasks (#33902)

* Make CanGc non-sendable, and add documentation.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Update CanGc usage to fix usages that were moved between threads/tasks.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-10-18 13:26:54 -04:00 committed by GitHub
parent a58da5aa83
commit b85093ad74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 69 additions and 89 deletions

View file

@ -294,7 +294,6 @@ impl ServiceWorkerGlobalScope {
control_receiver: Receiver<ServiceWorkerControlMsg>,
context_sender: Sender<ThreadSafeJSContext>,
closing: Arc<AtomicBool>,
can_gc: CanGc,
) -> JoinHandle<()> {
let ScopeThings {
script_url,
@ -384,7 +383,7 @@ impl ServiceWorkerGlobalScope {
scope.execute_script(DOMString::from(source));
}
global.dispatch_activate(can_gc);
global.dispatch_activate(CanGc::note());
let reporter_name = format!("service-worker-reporter-{}", random::<u64>());
scope
.upcast::<GlobalScope>()
@ -398,7 +397,7 @@ impl ServiceWorkerGlobalScope {
// which happens after the closing flag is set to true,
// or until the worker has run beyond its allocated time.
while !scope.is_closing() && !global.has_timed_out() {
run_worker_event_loop(&*global, None, can_gc);
run_worker_event_loop(&*global, None, CanGc::note());
}
},
reporter_name,