removing mutHeapJs references

changes as per comments
This commit is contained in:
SendilKumar N 2017-03-04 22:25:47 +08:00
parent c62973b77b
commit 2996d3a413
7 changed files with 23 additions and 67 deletions

View file

@ -5,7 +5,7 @@
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::js::{JS, Root, MutHeapJSVal};
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::DomObject;
use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
use dom::globalscope::GlobalScope;
@ -39,7 +39,7 @@ pub enum ExceptionHandling {
pub struct CallbackObject {
/// The underlying `JSObject`.
callback: Heap<*mut JSObject>,
permanent_js_root: MutHeapJSVal,
permanent_js_root: Heap<JSVal>,
/// The ["callback context"], that is, the global to use as incumbent
/// global when calling the callback.
@ -67,7 +67,7 @@ impl CallbackObject {
fn new() -> CallbackObject {
CallbackObject {
callback: Heap::default(),
permanent_js_root: MutHeapJSVal::new(),
permanent_js_root: Heap::default(),
incumbent: GlobalScope::incumbent().map(|i| JS::from_ref(&*i)),
}
}

View file

@ -31,8 +31,7 @@ use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::trace_reflector;
use dom::node::Node;
use heapsize::HeapSizeOf;
use js::jsapi::{Heap, JSObject, JSTracer};
use js::jsval::JSVal;
use js::jsapi::{JSObject, JSTracer};
use script_layout_interface::TrustedNodeAddress;
use script_thread::STACK_ROOTS;
use std::cell::UnsafeCell;
@ -229,49 +228,6 @@ impl LayoutJS<Node> {
}
}
/// A holder that provides interior mutability for GC-managed JSVals.
///
/// Must be used in place of traditional interior mutability to ensure proper
/// GC barriers are enforced.
#[must_root]
#[derive(JSTraceable)]
pub struct MutHeapJSVal {
val: UnsafeCell<Heap<JSVal>>,
}
impl MutHeapJSVal {
/// Create a new `MutHeapJSVal`.
pub fn new() -> MutHeapJSVal {
debug_assert!(thread_state::get().is_script());
MutHeapJSVal {
val: UnsafeCell::new(Heap::default()),
}
}
/// Set this `MutHeapJSVal` to the given value, calling write barriers as
/// appropriate.
pub fn set(&self, val: JSVal) {
debug_assert!(thread_state::get().is_script());
unsafe {
let cell = self.val.get();
(*cell).set(val);
}
}
/// Get the value in this `MutHeapJSVal`, calling read barriers as appropriate.
pub fn get(&self) -> JSVal {
debug_assert!(thread_state::get().is_script());
unsafe { (*self.val.get()).get() }
}
/// Get the underlying unsafe pointer to the contained value.
pub unsafe fn get_unsafe(&self) -> *mut JSVal {
debug_assert!(thread_state::get().is_script());
(*self.val.get()).get_unsafe()
}
}
/// A holder that provides interior mutability for GC-managed values such as
/// `JS<T>`. Essentially a `Cell<JS<T>>`, but safer.
///