servo: Merge #15108 - Don't try to get the global of an object while it's being destroyed (from servo:callbackobject-drop); r=KiChjang
authorMs2ger <Ms2ger@gmail.com>
Thu, 19 Jan 2017 03:05:17 -0800
changeset 340609 251f69873724e09de1373446632582ff46e01b01
parent 340608 92232856f4b2193a5c5043c97dfc5ac30f03b801
child 340610 3a52dfb50c6e0b2f65c7b75b7c694f91c293daad
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)
reviewersKiChjang
servo: Merge #15108 - Don't try to get the global of an object while it's being destroyed (from servo:callbackobject-drop); r=KiChjang Fixes #15070. Fixes #15097. Source-Repo: https://github.com/servo/servo Source-Revision: 2c816a2e9dfe3eb6952fd61f5a96cf26668ad9c8
servo/Cargo.lock
servo/components/script/dom/bindings/callback.rs
--- a/servo/Cargo.lock
+++ b/servo/Cargo.lock
@@ -1252,17 +1252,17 @@ source = "registry+https://github.com/ru
 dependencies = [
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "js"
 version = "0.1.3"
-source = "git+https://github.com/servo/rust-mozjs#568eccb62c8b139450d74bb8ed34e464ada715b2"
+source = "git+https://github.com/servo/rust-mozjs#71acb0c504abbbc9c396bd78c71af4ec4ea91c88"
 dependencies = [
  "cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
  "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/servo/components/script/dom/bindings/callback.rs
+++ b/servo/components/script/dom/bindings/callback.rs
@@ -10,16 +10,17 @@ use dom::bindings::reflector::DomObject;
 use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
 use dom::globalscope::GlobalScope;
 use js::jsapi::{Heap, MutableHandleObject};
 use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject, AddRawValueRoot};
 use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment, RemoveRawValueRoot};
 use js::jsapi::JSAutoCompartment;
 use js::jsapi::JS_GetProperty;
 use js::jsval::{JSVal, UndefinedValue, ObjectValue};
+use js::rust::Runtime;
 use std::default::Default;
 use std::ffi::CString;
 use std::mem::drop;
 use std::ops::Deref;
 use std::ptr;
 use std::rc::Rc;
 
 /// The exception handling used for a call.
@@ -83,17 +84,17 @@ impl CallbackObject {
                                 b"CallbackObject::root\n" as *const _ as *const _));
     }
 }
 
 impl Drop for CallbackObject {
     #[allow(unsafe_code)]
     fn drop(&mut self) {
         unsafe {
-            let cx = GlobalScope::from_object(self.callback.get()).get_cx();
+            let cx = Runtime::get();
             RemoveRawValueRoot(cx, self.permanent_js_root.get_unsafe());
         }
     }
 
 }
 
 impl PartialEq for CallbackObject {
     fn eq(&self, other: &CallbackObject) -> bool {