aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_runtime.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2018-12-02 14:58:15 -0500
committerJosh Matthews <josh@joshmatthews.net>2019-01-15 14:00:13 -0500
commit367014a4ea5b3fff5e4f33df199db0fdb7a95925 (patch)
treeda0e8b17e5064337c11877b1ef724e92a14f690a /components/script/script_runtime.rs
parent644101e1e42a98996ff98c4cb8fb3cb6dd18be94 (diff)
downloadservo-367014a4ea5b3fff5e4f33df199db0fdb7a95925.tar.gz
servo-367014a4ea5b3fff5e4f33df199db0fdb7a95925.zip
Reintroduce parent runtimes for worker threads.
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r--components/script/script_runtime.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs
index 29be8114e35..2ee27ab38bb 100644
--- a/components/script/script_runtime.rs
+++ b/components/script/script_runtime.rs
@@ -43,6 +43,7 @@ use js::rust::wrappers::{GetPromiseIsHandled, GetPromiseResult};
use js::rust::Handle;
use js::rust::IntoHandle;
use js::rust::JSEngine;
+use js::rust::ParentRuntime;
use js::rust::Runtime as RustRuntime;
use malloc_size_of::MallocSizeOfOps;
use msg::constellation_msg::PipelineId;
@@ -329,9 +330,23 @@ lazy_static! {
}
#[allow(unsafe_code)]
-pub unsafe fn new_rt_and_cx() -> Runtime {
+pub unsafe fn new_child_runtime(parent: ParentRuntime) -> Runtime {
+ new_rt_and_cx_with_parent(Some(parent))
+}
+
+#[allow(unsafe_code)]
+pub fn new_rt_and_cx() -> Runtime {
+ unsafe { new_rt_and_cx_with_parent(None) }
+}
+
+#[allow(unsafe_code)]
+unsafe fn new_rt_and_cx_with_parent(parent: Option<ParentRuntime>) -> Runtime {
LiveDOMReferences::initialize();
- let runtime = RustRuntime::new(JS_ENGINE.clone());
+ let runtime = if let Some(parent) = parent {
+ RustRuntime::create_with_parent(parent)
+ } else {
+ RustRuntime::new(JS_ENGINE.clone())
+ };
let cx = runtime.cx();
JS_AddExtraGCRootsTracer(cx, Some(trace_rust_roots), ptr::null_mut());