servo: Merge #10710 - Update js (from Ms2ger:js); r=nox
authorMs2ger <Ms2ger@gmail.com>
Thu, 21 Apr 2016 15:12:14 +0500
changeset 338584 f39e75d05950c4758be39e748f3ec274f39388a1
parent 338583 73046b7a5b8924fa5cc2c6185932b6c58f7335dd
child 338585 18f78fde988a32b94602e0d0137c188c37bed7e8
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #10710 - Update js (from Ms2ger:js); r=nox Source-Repo: https://github.com/servo/servo Source-Revision: 7e370c4df4ee0c564322a0bebd34b31359e88d85
servo/components/script/dom/dedicatedworkerglobalscope.rs
servo/components/script/script_runtime.rs
servo/components/script/script_thread.rs
servo/components/servo/Cargo.lock
servo/ports/cef/Cargo.lock
servo/ports/gonk/Cargo.lock
--- a/servo/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/servo/components/script/dom/dedicatedworkerglobalscope.rs
@@ -235,17 +235,17 @@ impl DedicatedWorkerGlobalScope {
                         box SimpleWorkerErrorHandler::new(worker))).unwrap();
                     return;
                 }
                 Ok((metadata, bytes)) => {
                     (metadata.final_url, String::from_utf8(bytes).unwrap())
                 }
             };
 
-            let runtime = new_rt_and_cx();
+            let runtime = unsafe { new_rt_and_cx() };
             *main_thread_rt.lock().unwrap() = Some(SharedRt::new(&runtime));
 
             let (devtools_mpsc_chan, devtools_mpsc_port) = channel();
             ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan);
 
             let (timer_tx, timer_rx) = channel();
             let (timer_ipc_chan, timer_ipc_port) = ipc::channel().unwrap();
             let worker_for_route = worker.clone();
--- a/servo/components/script/script_runtime.rs
+++ b/servo/components/script/script_runtime.rs
@@ -90,47 +90,40 @@ impl<'a> StackRootTLS<'a> {
 
 impl<'a> Drop for StackRootTLS<'a> {
     fn drop(&mut self) {
         STACK_ROOTS.with(|ref r| r.set(None));
     }
 }
 
 #[allow(unsafe_code)]
-pub fn new_rt_and_cx() -> Runtime {
+pub unsafe fn new_rt_and_cx() -> Runtime {
     LiveDOMReferences::initialize();
     let runtime = Runtime::new();
 
-    unsafe {
-        JS_AddExtraGCRootsTracer(runtime.rt(), Some(trace_rust_roots), ptr::null_mut());
-        JS_AddExtraGCRootsTracer(runtime.rt(), Some(trace_refcounted_objects), ptr::null_mut());
-    }
+    JS_AddExtraGCRootsTracer(runtime.rt(), Some(trace_rust_roots), ptr::null_mut());
+    JS_AddExtraGCRootsTracer(runtime.rt(), Some(trace_refcounted_objects), ptr::null_mut());
 
     // Needed for debug assertions about whether GC is running.
     if cfg!(debug_assertions) {
-        unsafe {
-            JS_SetGCCallback(runtime.rt(), Some(debug_gc_callback), ptr::null_mut());
-        }
+        JS_SetGCCallback(runtime.rt(), Some(debug_gc_callback), ptr::null_mut());
     }
+
     if opts::get().gc_profile {
-        unsafe {
-            SetGCSliceCallback(runtime.rt(), Some(gc_slice_callback));
-        }
+        SetGCSliceCallback(runtime.rt(), Some(gc_slice_callback));
     }
 
-    unsafe {
-        unsafe extern "C" fn empty_wrapper_callback(_: *mut JSContext, _: *mut JSObject) -> bool { true }
-        SetDOMCallbacks(runtime.rt(), &DOM_CALLBACKS);
-        SetPreserveWrapperCallback(runtime.rt(), Some(empty_wrapper_callback));
-        // Pre barriers aren't working correctly at the moment
-        DisableIncrementalGC(runtime.rt());
-    }
+    unsafe extern "C" fn empty_wrapper_callback(_: *mut JSContext, _: *mut JSObject) -> bool { true }
+    SetDOMCallbacks(runtime.rt(), &DOM_CALLBACKS);
+    SetPreserveWrapperCallback(runtime.rt(), Some(empty_wrapper_callback));
+    // Pre barriers aren't working correctly at the moment
+    DisableIncrementalGC(runtime.rt());
 
     // Enable or disable the JITs.
-    let rt_opts = unsafe { &mut *RuntimeOptionsRef(runtime.rt()) };
+    let rt_opts = &mut *RuntimeOptionsRef(runtime.rt());
     if let Some(val) = get_pref("js.baseline.enabled").as_boolean() {
         rt_opts.set_baseline_(val);
     }
     if let Some(val) = get_pref("js.ion.enabled").as_boolean() {
         rt_opts.set_ion_(val);
     }
     if let Some(val) = get_pref("js.asmjs.enabled").as_boolean() {
         rt_opts.set_asmJS_(val);
@@ -139,177 +132,139 @@ pub fn new_rt_and_cx() -> Runtime {
         rt_opts.set_extraWarnings_(val);
     }
     // TODO: handle js.strict.debug.enabled
     // TODO: handle js.throw_on_asmjs_validation_failure (needs new Spidermonkey)
     if let Some(val) = get_pref("js.native_regexp.enabled").as_boolean() {
         rt_opts.set_nativeRegExp_(val);
     }
     if let Some(val) = get_pref("js.parallel_parsing.enabled").as_boolean() {
-        unsafe { JS_SetParallelParsingEnabled(runtime.rt(), val); }
+        JS_SetParallelParsingEnabled(runtime.rt(), val);
     }
     if let Some(val) = get_pref("js.offthread_compilation_enabled").as_boolean() {
-        unsafe { JS_SetOffthreadIonCompilationEnabled(runtime.rt(), val); }
+        JS_SetOffthreadIonCompilationEnabled(runtime.rt(), val);
     }
     if let Some(val) = get_pref("js.baseline.unsafe_eager_compilation.enabled").as_boolean() {
         let trigger: i32 = if val {
             0
         } else {
             -1
         };
-        unsafe {
-            JS_SetGlobalJitCompilerOption(runtime.rt(),
-                                          JSJitCompilerOption::JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
-                                          trigger as u32);
-        }
+        JS_SetGlobalJitCompilerOption(runtime.rt(),
+                                      JSJitCompilerOption::JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
+                                      trigger as u32);
     }
     if let Some(val) = get_pref("js.ion.unsafe_eager_compilation.enabled").as_boolean() {
         let trigger: i64 = if val {
             0
         } else {
             -1
         };
-        unsafe {
-            JS_SetGlobalJitCompilerOption(runtime.rt(),
-                                          JSJitCompilerOption::JSJITCOMPILER_ION_WARMUP_TRIGGER,
-                                          trigger as u32);
-        }
+        JS_SetGlobalJitCompilerOption(runtime.rt(),
+                                      JSJitCompilerOption::JSJITCOMPILER_ION_WARMUP_TRIGGER,
+                                      trigger as u32);
     }
     // TODO: handle js.discard_system_source.enabled
     // TODO: handle js.asyncstack.enabled (needs new Spidermonkey)
     // TODO: handle js.throw_on_debugee_would_run (needs new Spidermonkey)
     // TODO: handle js.dump_stack_on_debugee_would_run (needs new Spidermonkey)
     if let Some(val) = get_pref("js.werror.enabled").as_boolean() {
         rt_opts.set_werror_(val);
     }
     // TODO: handle js.shared_memory.enabled
     if let Some(val) = get_pref("js.mem.high_water_mark").as_i64() {
-        unsafe {
-            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_MALLOC_BYTES, val as u32 * 1024 * 1024);
-        }
+        JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_MALLOC_BYTES, val as u32 * 1024 * 1024);
     }
     if let Some(val) = get_pref("js.mem.max").as_i64() {
         let max = if val <= 0 || val >= 0x1000 {
             -1
         } else {
             val * 1024 * 1024
         };
-        unsafe {
-            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_BYTES, max as u32);
-        }
+        JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_BYTES, max as u32);
     }
     // NOTE: This is disabled above, so enabling it here will do nothing for now.
     if let Some(val) = get_pref("js.mem.gc.incremental.enabled").as_boolean() {
         let compartment = if let Some(val) = get_pref("js.mem.gc.per_compartment.enabled").as_boolean() {
             val
         } else {
             false
         };
         let mode = if val {
             JSGCMode::JSGC_MODE_INCREMENTAL
         } else if compartment {
             JSGCMode::JSGC_MODE_COMPARTMENT
         } else {
             JSGCMode::JSGC_MODE_GLOBAL
         };
-        unsafe {
-            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MODE, mode as u32);
-        }
+        JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MODE, mode as u32);
     }
     if let Some(val) = get_pref("js.mem.gc.incremental.slice_ms").as_i64() {
         if val >= 0 && val < 100000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_SLICE_TIME_BUDGET, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_SLICE_TIME_BUDGET, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.compacting.enabled").as_boolean() {
-        unsafe {
-            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_COMPACTING_ENABLED, val as u32);
-        }
+        JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_COMPACTING_ENABLED, val as u32);
     }
     if let Some(val) = get_pref("js.mem.gc.high_frequency_time_limit_ms").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_TIME_LIMIT, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_TIME_LIMIT, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.dynamic_mark_slice.enabled").as_boolean() {
-        unsafe {
-            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DYNAMIC_MARK_SLICE, val as u32);
-        }
+        JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DYNAMIC_MARK_SLICE, val as u32);
     }
     // TODO: handle js.mem.gc.refresh_frame_slices.enabled
     if let Some(val) = get_pref("js.mem.gc.dynamic_heap_growth.enabled").as_boolean() {
-        unsafe {
-            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DYNAMIC_HEAP_GROWTH, val as u32);
-        }
+        JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DYNAMIC_HEAP_GROWTH, val as u32);
     }
     if let Some(val) = get_pref("js.mem.gc.low_frequency_heap_growth").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_LOW_FREQUENCY_HEAP_GROWTH, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_LOW_FREQUENCY_HEAP_GROWTH, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.high_frequency_heap_growth_min").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.high_frequency_heap_growth_max").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.high_frequency_low_limit_mb").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_LOW_LIMIT, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_LOW_LIMIT, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.high_frequency_high_limit_mb").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HIGH_LIMIT, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HIGH_LIMIT, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.allocation_threshold_mb").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_ALLOCATION_THRESHOLD, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_ALLOCATION_THRESHOLD, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.decommit_threshold_mb").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DECOMMIT_THRESHOLD, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DECOMMIT_THRESHOLD, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.empty_chunk_count_min").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MIN_EMPTY_CHUNK_COUNT, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MIN_EMPTY_CHUNK_COUNT, val as u32);
         }
     }
     if let Some(val) = get_pref("js.mem.gc.empty_chunk_count_max").as_i64() {
         if val >= 0 && val < 10000 {
-            unsafe {
-                JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_EMPTY_CHUNK_COUNT, val as u32);
-            }
+            JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_EMPTY_CHUNK_COUNT, val as u32);
         }
     }
 
     runtime
 }
 
 #[allow(unsafe_code)]
 pub fn get_reports(cx: *mut JSContext, path_seg: String) -> Vec<Report> {
--- a/servo/components/script/script_thread.rs
+++ b/servo/components/script/script_thread.rs
@@ -516,17 +516,17 @@ impl ScriptThread {
         });
     }
 
     /// Creates a new script thread.
     pub fn new(state: InitialScriptState,
                port: Receiver<MainThreadScriptMsg>,
                chan: Sender<MainThreadScriptMsg>)
                -> ScriptThread {
-        let runtime = new_rt_and_cx();
+        let runtime = unsafe { new_rt_and_cx() };
 
         unsafe {
             JS_SetWrapObjectCallbacks(runtime.rt(),
                                       &WRAP_CALLBACKS);
         }
 
         // Ask the router to proxy IPC messages from the devtools to us.
         let (ipc_devtools_sender, ipc_devtools_receiver) = ipc::channel().unwrap();
--- a/servo/components/servo/Cargo.lock
+++ b/servo/components/servo/Cargo.lock
@@ -978,17 +978,17 @@ dependencies = [
  "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "js"
 version = "0.1.2"
-source = "git+https://github.com/servo/rust-mozjs#6f1eb4ea7a84714bfab2806440c9fc8a9a261409"
+source = "git+https://github.com/servo/rust-mozjs#efe805affa75d776316e9ea6113f85cdad1e82ed"
 dependencies = [
  "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
  "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
--- a/servo/ports/cef/Cargo.lock
+++ b/servo/ports/cef/Cargo.lock
@@ -898,17 +898,17 @@ dependencies = [
  "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "js"
 version = "0.1.2"
-source = "git+https://github.com/servo/rust-mozjs#6f1eb4ea7a84714bfab2806440c9fc8a9a261409"
+source = "git+https://github.com/servo/rust-mozjs#efe805affa75d776316e9ea6113f85cdad1e82ed"
 dependencies = [
  "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
  "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
--- a/servo/ports/gonk/Cargo.lock
+++ b/servo/ports/gonk/Cargo.lock
@@ -880,17 +880,17 @@ dependencies = [
  "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "js"
 version = "0.1.2"
-source = "git+https://github.com/servo/rust-mozjs#6f1eb4ea7a84714bfab2806440c9fc8a9a261409"
+source = "git+https://github.com/servo/rust-mozjs#efe805affa75d776316e9ea6113f85cdad1e82ed"
 dependencies = [
  "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
  "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]