Remove reference counting from the Runtime implementation.

This commit is contained in:
Ms2ger 2015-05-10 17:02:32 +02:00
parent 9abe47b76f
commit cfe240d117
7 changed files with 17 additions and 15 deletions

View file

@ -36,10 +36,11 @@ use util::task_state::{SCRIPT, IN_WORKER};
use js::jsapi::JSContext;
use js::jsval::JSVal;
use js::rust::Runtime;
use std::sync::mpsc::{Sender, Receiver, channel};
use url::Url;
use std::rc::Rc;
use std::sync::mpsc::{Sender, Receiver, channel};
/// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with
/// every message. While this SendableWorkerScriptChan is alive, the associated Worker object
/// will remain alive.
@ -105,7 +106,7 @@ impl DedicatedWorkerGlobalScope {
fn new_inherited(worker_url: Url,
id: PipelineId,
devtools_chan: Option<DevtoolsControlChan>,
runtime: Runtime,
runtime: Rc<Runtime>,
resource_task: ResourceTask,
parent_sender: Box<ScriptChan+Send>,
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
@ -126,7 +127,7 @@ impl DedicatedWorkerGlobalScope {
pub fn new(worker_url: Url,
id: PipelineId,
devtools_chan: Option<DevtoolsControlChan>,
runtime: Runtime,
runtime: Rc<Runtime>,
resource_task: ResourceTask,
parent_sender: Box<ScriptChan+Send>,
own_sender: Sender<(TrustedWorkerAddress, ScriptMsg)>,
@ -166,7 +167,7 @@ impl DedicatedWorkerGlobalScope {
}
};
let runtime = ScriptTask::new_rt_and_cx();
let runtime = Rc::new(ScriptTask::new_rt_and_cx());
let global = DedicatedWorkerGlobalScope::new(
worker_url, id, devtools_chan, runtime.clone(), resource_task,
parent_sender, own_sender, receiver).root();

View file

@ -134,7 +134,7 @@ pub struct Window {
dom_static: GlobalStaticData,
/// The JavaScript runtime.
js_runtime: DOMRefCell<Option<Runtime>>,
js_runtime: DOMRefCell<Option<Rc<Runtime>>>,
/// A handle for communicating messages to the layout task.
layout_chan: LayoutChan,
@ -883,7 +883,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
}
impl Window {
pub fn new(runtime: Runtime,
pub fn new(runtime: Rc<Runtime>,
page: Rc<Page>,
script_chan: Box<ScriptChan+Send>,
image_cache_chan: ImageCacheChan,

View file

@ -28,10 +28,11 @@ use util::str::DOMString;
use js::jsapi::JSContext;
use js::jsval::JSVal;
use js::rust::Runtime;
use url::{Url, UrlParser};
use std::default::Default;
use std::cell::Cell;
use url::{Url, UrlParser};
use std::rc::Rc;
#[derive(Copy, Clone, PartialEq)]
#[jstraceable]
@ -44,7 +45,7 @@ pub enum WorkerGlobalScopeTypeId {
pub struct WorkerGlobalScope {
eventtarget: EventTarget,
worker_url: Url,
runtime: Runtime,
runtime: Rc<Runtime>,
next_worker_id: Cell<WorkerId>,
resource_task: ResourceTask,
location: MutNullableHeap<JS<WorkerLocation>>,
@ -57,7 +58,7 @@ pub struct WorkerGlobalScope {
impl WorkerGlobalScope {
pub fn new_inherited(type_id: WorkerGlobalScopeTypeId,
worker_url: Url,
runtime: Runtime,
runtime: Rc<Runtime>,
resource_task: ResourceTask,
devtools_chan: Option<DevtoolsControlChan>) -> WorkerGlobalScope {
WorkerGlobalScope {

View file

@ -312,7 +312,7 @@ pub struct ScriptTask {
devtools_marker_sender: RefCell<Option<Sender<TimelineMarker>>>,
/// The JavaScript runtime.
js_runtime: Runtime,
js_runtime: Rc<Runtime>,
mouse_over_targets: DOMRefCell<Vec<JS<Node>>>
}
@ -491,7 +491,7 @@ impl ScriptTask {
devtools_markers: RefCell::new(HashSet::new()),
devtools_marker_sender: RefCell::new(None),
js_runtime: runtime,
js_runtime: Rc::new(runtime),
mouse_over_targets: DOMRefCell::new(vec!())
}
}

View file

@ -579,7 +579,7 @@ dependencies = [
[[package]]
name = "js"
version = "0.1.0"
source = "git+https://github.com/servo/rust-mozjs#774a764770b196ed64e4973744f9d2ff247412b1"
source = "git+https://github.com/servo/rust-mozjs#18f507903856a814f12cce2ffda8065695d8f485"
dependencies = [
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/cef/Cargo.lock generated
View file

@ -581,7 +581,7 @@ dependencies = [
[[package]]
name = "js"
version = "0.1.0"
source = "git+https://github.com/servo/rust-mozjs#774a764770b196ed64e4973744f9d2ff247412b1"
source = "git+https://github.com/servo/rust-mozjs#18f507903856a814f12cce2ffda8065695d8f485"
dependencies = [
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/gonk/Cargo.lock generated
View file

@ -479,7 +479,7 @@ dependencies = [
[[package]]
name = "js"
version = "0.1.0"
source = "git+https://github.com/servo/rust-mozjs#774a764770b196ed64e4973744f9d2ff247412b1"
source = "git+https://github.com/servo/rust-mozjs#18f507903856a814f12cce2ffda8065695d8f485"
dependencies = [
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",