diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-04-10 08:44:38 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-04-10 08:44:38 -0500 |
commit | 35fb5166624faa13d8a7090ce3f2456726547e11 (patch) | |
tree | e0bc2a7ee8841490d861a350662ca5f9bbf56d7c | |
parent | 9677eb292dacd26ea21ab12441b88d538d719814 (diff) | |
parent | 95e4e259245f67127aef673cc58b1112d5e416e2 (diff) | |
download | servo-35fb5166624faa13d8a7090ce3f2456726547e11.tar.gz servo-35fb5166624faa13d8a7090ce3f2456726547e11.zip |
Auto merge of #5632 - Ms2ger:runtime, r=jdm
-rw-r--r-- | components/script/dom/bindings/trace.rs | 2 | ||||
-rw-r--r-- | components/script/script_task.rs | 44 | ||||
-rw-r--r-- | components/servo/Cargo.lock | 2 | ||||
-rw-r--r-- | ports/cef/Cargo.lock | 2 | ||||
-rw-r--r-- | ports/gonk/Cargo.lock | 2 |
5 files changed, 14 insertions, 38 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index f77b42648d9..4b5dffc1875 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -428,7 +428,7 @@ impl<T> DerefMut for RootedVec<T> { /// SM Callback that traces the rooted collections -pub unsafe extern fn trace_collections(tracer: *mut JSTracer, _data: *mut libc::c_void) { +pub unsafe fn trace_collections(tracer: *mut JSTracer) { ROOTED_COLLECTIONS.with(|ref collections| { let collections = collections.borrow(); collections.trace(tracer); diff --git a/components/script/script_task.rs b/components/script/script_task.rs index dbb73117857..6334dcb26a0 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -74,11 +74,10 @@ use util::task_state; use geom::Rect; use geom::point::Point2D; use hyper::header::{LastModified, Headers}; -use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_SetExtraGCRootsTracer, JS_DEFAULT_ZEAL_FREQ}; +use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetExtraGCRootsTracer}; use js::jsapi::{JSContext, JSRuntime, JSObject, JSTracer}; -use js::jsapi::{JS_SetGCParameter, JSGC_MAX_BYTES}; use js::jsapi::{JS_SetGCCallback, JSGCStatus, JSGC_BEGIN, JSGC_END}; -use js::rust::{Cx, RtUtils}; +use js::rust::{Runtime, Cx, RtUtils}; use js; use url::Url; @@ -93,18 +92,19 @@ use std::ptr; use std::rc::Rc; use std::result::Result; use std::sync::mpsc::{channel, Sender, Receiver, Select}; -use std::u32; use time::Tm; thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None)); thread_local!(static SCRIPT_TASK_ROOT: RefCell<Option<*const ScriptTask>> = RefCell::new(None)); -unsafe extern fn trace_script_tasks(tr: *mut JSTracer, _data: *mut libc::c_void) { +unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut libc::c_void) { SCRIPT_TASK_ROOT.with(|root| { if let Some(script_task) = *root.borrow() { (*script_task).trace(tr); } }); + + trace_collections(tr); } /// A document load that is in the process of fetching the requested resource. Contains @@ -237,6 +237,7 @@ impl Drop for StackRootTLS { } } + /// Information for an entire page. Pages are top-level browsing contexts and can contain multiple /// frames. /// @@ -455,46 +456,21 @@ impl ScriptTask { pub fn new_rt_and_cx() -> (js::rust::rt, Rc<Cx>) { LiveDOMReferences::initialize(); - let js_runtime = js::rust::rt(); - assert!({ - let ptr: *mut JSRuntime = (*js_runtime).ptr; - !ptr.is_null() - }); - - - unsafe { - JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_collections), ptr::null_mut()); - } - // Unconstrain the runtime's threshold on nominal heap size, to avoid - // triggering GC too often if operating continuously near an arbitrary - // finite threshold. This leaves the maximum-JS_malloc-bytes threshold - // still in effect to cause periodical, and we hope hygienic, - // last-ditch GCs from within the GC's allocator. - unsafe { - JS_SetGCParameter(js_runtime.ptr, JSGC_MAX_BYTES, u32::MAX); - } + let runtime = Runtime::new(); - let js_context = js_runtime.cx(); - assert!({ - let ptr: *mut JSContext = (*js_context).ptr; - !ptr.is_null() - }); - js_context.set_default_options_and_version(); - js_context.set_logging_error_reporter(); unsafe { - JS_SetGCZeal((*js_context).ptr, 0, JS_DEFAULT_ZEAL_FREQ); - JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_script_tasks), ptr::null_mut()); + JS_SetExtraGCRootsTracer(runtime.rt(), Some(trace_rust_roots), ptr::null_mut()); } // Needed for debug assertions about whether GC is running. if !cfg!(ndebug) { unsafe { - JS_SetGCCallback(js_runtime.ptr, + JS_SetGCCallback(runtime.rt(), Some(debug_gc_callback as unsafe extern "C" fn(*mut JSRuntime, JSGCStatus))); } } - (js_runtime, js_context) + (runtime.rt, runtime.cx) } // Return the root page in the frame tree. Panics if it doesn't exist. diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index d61b2571292..4d332f65ad2 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -479,7 +479,7 @@ dependencies = [ [[package]] name = "js" version = "0.1.0" -source = "git+https://github.com/servo/rust-mozjs#9512c3c770774ed73a2fdcc635eee178cbd02ab1" +source = "git+https://github.com/servo/rust-mozjs#402b7b2db8816ffeccacfa9a8d316f4487e96ba0" dependencies = [ "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 3fcab77d28b..5d9eedbe5ef 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "js" version = "0.1.0" -source = "git+https://github.com/servo/rust-mozjs#9512c3c770774ed73a2fdcc635eee178cbd02ab1" +source = "git+https://github.com/servo/rust-mozjs#402b7b2db8816ffeccacfa9a8d316f4487e96ba0" dependencies = [ "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 7de597c61f9..07ef23c5293 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -415,7 +415,7 @@ dependencies = [ [[package]] name = "js" version = "0.1.0" -source = "git+https://github.com/servo/rust-mozjs#9512c3c770774ed73a2fdcc635eee178cbd02ab1" +source = "git+https://github.com/servo/rust-mozjs#402b7b2db8816ffeccacfa9a8d316f4487e96ba0" dependencies = [ "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)", |