diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-03-30 10:42:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 10:42:23 -0400 |
commit | fd6f9140f79a855b9db5fe4e305f8ca8b6c1a84f (patch) | |
tree | 2d94d2c28ddcfbb4d54e7e24855e2df48da9a63c /components/script/script_runtime.rs | |
parent | c3ecf2ecef36bfc35ba75442c81d54fd2bc695be (diff) | |
parent | 3ce61098363bd7be5a633d19ede38dcdab108502 (diff) | |
download | servo-fd6f9140f79a855b9db5fe4e305f8ca8b6c1a84f.tar.gz servo-fd6f9140f79a855b9db5fe4e305f8ca8b6c1a84f.zip |
Auto merge of #26056 - gterzian:enable_atomics_wait_on_dedicated_worker, r=jdm
Enable Atomics.wait in a dedicated worker agent
<!-- Please describe your changes on the following line: -->
FIX #25191
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index abe411521af..c9f804596d0 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -45,6 +45,7 @@ use js::jsapi::ContextOptionsRef; use js::jsapi::GetPromiseUserInputEventHandlingState; use js::jsapi::InitConsumeStreamCallback; use js::jsapi::InitDispatchToEventLoop; +use js::jsapi::JS_SetFutexCanWait; use js::jsapi::MimeType; use js::jsapi::PromiseUserInputEventHandlingState; use js::jsapi::StreamConsumer as JSStreamConsumer; @@ -454,12 +455,22 @@ unsafe fn new_rt_and_cx_with_parent( networking_task_source: Option<NetworkingTaskSource>, ) -> Runtime { LiveDOMReferences::initialize(); - let runtime = if let Some(parent) = parent { - RustRuntime::create_with_parent(parent) + let (cx, runtime) = if let Some(parent) = parent { + let runtime = RustRuntime::create_with_parent(parent); + let cx = runtime.cx(); + + // Note: this enables blocking on an Atomics.wait, + // which should only be enabled for an agent whose [[CanBlock]] is true. + // Currently only a dedicated worker agent uses a parent, + // and this agent can block. + // See https://html.spec.whatwg.org/multipage/#integration-with-the-javascript-agent-cluster-formalism + JS_SetFutexCanWait(cx); + + (cx, runtime) } else { - RustRuntime::new(JS_ENGINE.lock().unwrap().as_ref().unwrap().clone()) + let runtime = RustRuntime::new(JS_ENGINE.lock().unwrap().as_ref().unwrap().clone()); + (runtime.cx(), runtime) }; - let cx = runtime.cx(); JS_AddExtraGCRootsTracer(cx, Some(trace_rust_roots), ptr::null_mut()); |