diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-01-24 11:50:43 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-01-24 11:50:43 +0100 |
commit | f1738ee266ea341995c0ca3957a9f280dab54b34 (patch) | |
tree | 93d092a3178e9d92ebaca31ffb0694e7f8042e87 | |
parent | 231481570e7ffc6c036b54a15507a9b2260ffe87 (diff) | |
download | servo-f1738ee266ea341995c0ca3957a9f280dab54b34.tar.gz servo-f1738ee266ea341995c0ca3957a9f280dab54b34.zip |
Revert "Auto merge of #15136 - nox:mitochondria-finally-makes-it-into-the-tree, r=jdm"
This reverts commit ca6376a7142640185f21beca4b11011e8367ec91, reversing
changes made to bb24fd3177cd69931d6a894bfcbb605286cefa1e.
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | components/script/Cargo.toml | 1 | ||||
-rw-r--r-- | components/script/lib.rs | 1 | ||||
-rw-r--r-- | components/script/script_thread.rs | 72 |
4 files changed, 42 insertions, 39 deletions
diff --git a/Cargo.lock b/Cargo.lock index 1cd9a8192a0..b18666d7d81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1625,11 +1625,6 @@ dependencies = [ ] [[package]] -name = "mitochondria" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "mozjs_sys" version = "0.0.0" source = "git+https://github.com/servo/mozjs#7cd72d8c8f44f43ba162bdd814ec85e81b79cfb4" @@ -2287,7 +2282,6 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3515,7 +3509,6 @@ dependencies = [ "checksum miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d1f4d337a01c32e1f2122510fed46393d53ca35a7f429cb0450abaedfa3ed54" "checksum mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a637d1ca14eacae06296a008fa7ad955347e34efcb5891cfd8ba05491a37907e" "checksum miow 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3e690c5df6b2f60acd45d56378981e827ff8295562fc8d34f573deb267a59cd1" -"checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f" "checksum mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)" = "<none>" "checksum mp3-metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2f61cf32f7fc3cec83a15a255ac60bceb6cac59a7ce190cb824ca25c0fce0feb" "checksum mp4parse 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1736d06703a9cb5228b5a8151acc79bf5ba7669a810243852bcad4d3a25504" diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 258ae0e1105..bb34846065d 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -53,7 +53,6 @@ libc = "0.2" log = "0.3.5" mime = "0.2.1" mime_guess = "1.8.0" -mitochondria = "1.1.2" msg = {path = "../msg"} net_traits = {path = "../net_traits"} num-traits = "0.1.32" diff --git a/components/script/lib.rs b/components/script/lib.rs index aaac06e6ea7..0ee202fab01 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -63,7 +63,6 @@ extern crate log; #[macro_use] extern crate mime; extern crate mime_guess; -extern crate mitochondria; extern crate msg; extern crate net_traits; extern crate num_traits; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index db9a53816a2..57cdd7044c4 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -70,7 +70,6 @@ use js::jsval::UndefinedValue; use js::rust::Runtime; use layout_wrapper::ServoLayoutNode; use mem::heap_size_of_self_and_children; -use mitochondria::OnceCell; use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespace}; use net_traits::{CoreResourceMsg, FetchMetadata, FetchResponseListener}; use net_traits::{IpcSend, Metadata, ReferrerPolicy, ResourceThreads}; @@ -121,13 +120,13 @@ use webdriver_handlers; use webvr_traits::WebVRMsg; thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None)); -thread_local!(static SCRIPT_THREAD_ROOT: OnceCell<ScriptThread> = OnceCell::new()); +thread_local!(static SCRIPT_THREAD_ROOT: Cell<Option<*const ScriptThread>> = Cell::new(None)); pub unsafe fn trace_thread(tr: *mut JSTracer) { SCRIPT_THREAD_ROOT.with(|root| { - if let Some(script_thread) = root.as_ref() { + if let Some(script_thread) = root.get() { debug!("tracing fields of ScriptThread"); - script_thread.trace(tr); + (*script_thread).trace(tr); } }); } @@ -535,26 +534,29 @@ impl ScriptThreadFactory for ScriptThread { let parent_info = state.parent_info; let mem_profiler_chan = state.mem_profiler_chan.clone(); let window_size = state.window_size; + let script_thread = ScriptThread::new(state, + script_port, + script_chan.clone()); SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = root.init_once(|| ScriptThread::new(state, script_port, script_chan.clone())); + root.set(Some(&script_thread as *const _)); + }); - let mut failsafe = ScriptMemoryFailsafe::new(&script_thread); + let mut failsafe = ScriptMemoryFailsafe::new(&script_thread); - let origin = Origin::new(&load_data.url); - let new_load = InProgressLoad::new(id, frame_id, parent_info, layout_chan, window_size, - load_data.url.clone(), origin); - script_thread.start_page_load(new_load, load_data); + let origin = Origin::new(&load_data.url); + let new_load = InProgressLoad::new(id, frame_id, parent_info, layout_chan, window_size, + load_data.url.clone(), origin); + script_thread.start_page_load(new_load, load_data); - let reporter_name = format!("script-reporter-{}", id); - mem_profiler_chan.run_with_memory_reporting(|| { - script_thread.start(); - let _ = script_thread.content_process_shutdown_chan.send(()); - }, reporter_name, script_chan, CommonScriptMsg::CollectReports); + let reporter_name = format!("script-reporter-{}", id); + mem_profiler_chan.run_with_memory_reporting(|| { + script_thread.start(); + let _ = script_thread.content_process_shutdown_chan.send(()); + }, reporter_name, script_chan, CommonScriptMsg::CollectReports); - // This must always be the very last operation performed before the thread completes - failsafe.neuter(); - }); + // This must always be the very last operation performed before the thread completes + failsafe.neuter(); }).expect("Thread spawning failed"); (sender, receiver) @@ -565,7 +567,7 @@ impl ScriptThread { pub fn page_headers_available(id: &PipelineId, metadata: Option<Metadata>) -> Option<Root<ServoParser>> { SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = root.as_ref().unwrap(); + let script_thread = unsafe { &*root.get().unwrap() }; script_thread.handle_page_headers_available(id, metadata) }) } @@ -573,7 +575,7 @@ impl ScriptThread { #[allow(unrooted_must_root)] pub fn schedule_job(job: Job, global: &GlobalScope) { SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = root.as_ref().unwrap(); + let script_thread = unsafe { &*root.get().unwrap() }; let job_queue = &*script_thread.job_queue_map; job_queue.schedule_job(job, global, &script_thread); }); @@ -581,7 +583,8 @@ impl ScriptThread { pub fn process_event(msg: CommonScriptMsg) { SCRIPT_THREAD_ROOT.with(|root| { - if let Some(script_thread) = root.as_ref() { + if let Some(script_thread) = root.get() { + let script_thread = unsafe { &*script_thread }; script_thread.handle_msg_from_script(MainThreadScriptMsg::Common(msg)); } }); @@ -591,7 +594,8 @@ impl ScriptThread { pub fn await_stable_state<T: Runnable + Send + 'static>(task: T) { //TODO use microtasks when they exist SCRIPT_THREAD_ROOT.with(|root| { - if let Some(script_thread) = root.as_ref() { + if let Some(script_thread) = root.get() { + let script_thread = unsafe { &*script_thread }; let _ = script_thread.chan.send(CommonScriptMsg::RunnableMsg( ScriptThreadEventCategory::DomEvent, box task)); @@ -601,7 +605,8 @@ impl ScriptThread { pub fn process_attach_layout(new_layout_info: NewLayoutInfo, origin: Origin) { SCRIPT_THREAD_ROOT.with(|root| { - if let Some(script_thread) = root.as_ref() { + if let Some(script_thread) = root.get() { + let script_thread = unsafe { &*script_thread }; script_thread.profile_event(ScriptThreadEventCategory::AttachLayout, || { script_thread.handle_new_layout(new_layout_info, origin); }) @@ -610,11 +615,10 @@ impl ScriptThread { } pub fn find_document(id: PipelineId) -> Option<Root<Document>> { - SCRIPT_THREAD_ROOT.with(|root| { - root.as_ref().and_then(|script_thread| { - script_thread.documents.borrow().find_document(id) - }) - }) + SCRIPT_THREAD_ROOT.with(|root| root.get().and_then(|script_thread| { + let script_thread = unsafe { &*script_thread }; + script_thread.documents.borrow().find_document(id) + })) } /// Creates a new script thread. @@ -2163,14 +2167,14 @@ impl ScriptThread { pub fn enqueue_promise_job(job: EnqueuedPromiseCallback, global: &GlobalScope) { SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = root.as_ref().unwrap(); + let script_thread = unsafe { &*root.get().unwrap() }; script_thread.promise_job_queue.enqueue(job, global); }); } pub fn flush_promise_jobs(global: &GlobalScope) { SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = root.as_ref().unwrap(); + let script_thread = unsafe { &*root.get().unwrap() }; let _ = script_thread.dom_manipulation_task_source.queue( box FlushPromiseJobs, global); }) @@ -2188,6 +2192,14 @@ impl Runnable for FlushPromiseJobs { } } +impl Drop for ScriptThread { + fn drop(&mut self) { + SCRIPT_THREAD_ROOT.with(|root| { + root.set(None); + }); + } +} + /// Shuts down layout for the given window. fn shut_down_layout(window: &Window) { // Tell the layout thread to begin shutting down, and wait until it |