aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r--components/script/dom/bindings/js.rs60
1 files changed, 30 insertions, 30 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index dfe1acca376..5fb452883f3 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -33,7 +33,7 @@ use dom::node::Node;
use js::jsapi::{Heap, JSObject, JSTracer};
use js::jsval::JSVal;
use layout_interface::TrustedNodeAddress;
-use script_task::STACK_ROOTS;
+use script_thread::STACK_ROOTS;
use std::cell::UnsafeCell;
use std::default::Default;
use std::hash::{Hash, Hasher};
@@ -41,7 +41,7 @@ use std::mem;
use std::ops::Deref;
use std::ptr;
use util::mem::HeapSizeOf;
-use util::task_state;
+use util::thread_state;
/// A traced reference to a DOM object
///
@@ -66,7 +66,7 @@ impl<T> HeapSizeOf for JS<T> {
impl<T> JS<T> {
/// Returns `LayoutJS<T>` containing the same pointer.
pub unsafe fn to_layout(&self) -> LayoutJS<T> {
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
LayoutJS {
ptr: self.ptr.clone(),
}
@@ -78,7 +78,7 @@ impl<T: Reflectable> JS<T> {
/// XXX Not a great API. Should be a call on Root<T> instead
#[allow(unrooted_must_root)]
pub fn from_rooted(root: &Root<T>) -> JS<T> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
JS {
ptr: unsafe { NonZero::new(&**root) },
}
@@ -86,7 +86,7 @@ impl<T: Reflectable> JS<T> {
/// Create a JS<T> from a &T
#[allow(unrooted_must_root)]
pub fn from_ref(obj: &T) -> JS<T> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
JS {
ptr: unsafe { NonZero::new(&*obj) },
}
@@ -97,7 +97,7 @@ impl<T: Reflectable> Deref for JS<T> {
type Target = T;
fn deref(&self) -> &T {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
// We can only have &JS<T> from a rooted thing, so it's safe to deref
// it to &T.
unsafe { &**self.ptr }
@@ -123,7 +123,7 @@ impl<T: Castable> LayoutJS<T> {
where U: Castable,
T: DerivedFrom<U>
{
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
unsafe { mem::transmute_copy(self) }
}
@@ -131,7 +131,7 @@ impl<T: Castable> LayoutJS<T> {
pub fn downcast<U>(&self) -> Option<LayoutJS<U>>
where U: DerivedFrom<T>
{
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
unsafe {
if (*self.unsafe_get()).is::<U>() {
Some(mem::transmute_copy(self))
@@ -145,7 +145,7 @@ impl<T: Castable> LayoutJS<T> {
impl<T: Reflectable> LayoutJS<T> {
/// Get the reflector.
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
(**self.ptr).reflector().get_jsobject().get()
}
}
@@ -184,7 +184,7 @@ impl <T> Clone for JS<T> {
#[inline]
#[allow(unrooted_must_root)]
fn clone(&self) -> JS<T> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
JS {
ptr: self.ptr.clone(),
}
@@ -194,7 +194,7 @@ impl <T> Clone for JS<T> {
impl <T> Clone for LayoutJS<T> {
#[inline]
fn clone(&self) -> LayoutJS<T> {
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
LayoutJS {
ptr: self.ptr.clone(),
}
@@ -205,7 +205,7 @@ impl LayoutJS<Node> {
/// Create a new JS-owned value wrapped from an address known to be a
/// `Node` pointer.
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS<Node> {
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
let TrustedNodeAddress(addr) = inner;
LayoutJS {
ptr: NonZero::new(addr as *const Node),
@@ -240,7 +240,7 @@ pub struct MutHeapJSVal {
impl MutHeapJSVal {
/// Create a new `MutHeapJSVal`.
pub fn new() -> MutHeapJSVal {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
MutHeapJSVal {
val: UnsafeCell::new(Heap::default()),
}
@@ -249,7 +249,7 @@ impl MutHeapJSVal {
/// Set this `MutHeapJSVal` to the given value, calling write barriers as
/// appropriate.
pub fn set(&self, val: JSVal) {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
let cell = self.val.get();
(*cell).set(val);
@@ -258,7 +258,7 @@ impl MutHeapJSVal {
/// Get the value in this `MutHeapJSVal`, calling read barriers as appropriate.
pub fn get(&self) -> JSVal {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe { (*self.val.get()).get() }
}
}
@@ -278,7 +278,7 @@ pub struct MutHeap<T: HeapGCValue> {
impl<T: Reflectable> MutHeap<JS<T>> {
/// Create a new `MutHeap`.
pub fn new(initial: &T) -> MutHeap<JS<T>> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
MutHeap {
val: UnsafeCell::new(JS::from_ref(initial)),
}
@@ -286,7 +286,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
/// Set this `MutHeap` to the given value.
pub fn set(&self, val: &T) {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
*self.val.get() = JS::from_ref(val);
}
@@ -294,7 +294,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
/// Get the value in this `MutHeap`.
pub fn get(&self) -> Root<T> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
Root::from_ref(&*ptr::read(self.val.get()))
}
@@ -339,7 +339,7 @@ pub struct MutNullableHeap<T: HeapGCValue> {
impl<T: Reflectable> MutNullableHeap<JS<T>> {
/// Create a new `MutNullableHeap`.
pub fn new(initial: Option<&T>) -> MutNullableHeap<JS<T>> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
MutNullableHeap {
ptr: UnsafeCell::new(initial.map(JS::from_ref)),
}
@@ -350,7 +350,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
pub fn or_init<F>(&self, cb: F) -> Root<T>
where F: FnOnce() -> Root<T>
{
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
match self.get() {
Some(inner) => inner,
None => {
@@ -365,14 +365,14 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
/// For use by layout, which can't use safe types like Temporary.
#[allow(unrooted_must_root)]
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
ptr::read(self.ptr.get()).map(|js| js.to_layout())
}
/// Get a rooted value out of this object
#[allow(unrooted_must_root)]
pub fn get(&self) -> Option<Root<T>> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o))
}
@@ -380,7 +380,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
/// Set this `MutNullableHeap` to the given value.
pub fn set(&self, val: Option<&T>) {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
*self.ptr.get() = val.map(|p| JS::from_ref(p));
}
@@ -407,7 +407,7 @@ impl<'a, T: Reflectable> PartialEq<Option<&'a T>> for MutNullableHeap<JS<T>> {
impl<T: HeapGCValue> Default for MutNullableHeap<T> {
#[allow(unrooted_must_root)]
fn default() -> MutNullableHeap<T> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
MutNullableHeap {
ptr: UnsafeCell::new(None),
}
@@ -426,7 +426,7 @@ impl<T: Reflectable> LayoutJS<T> {
/// the only method that be safely accessed from layout. (The fact that
/// this is unsafe is what necessitates the layout wrappers.)
pub unsafe fn unsafe_get(&self) -> *const T {
- debug_assert!(task_state::get().is_layout());
+ debug_assert!(thread_state::get().is_layout());
*self.ptr
}
}
@@ -479,7 +479,7 @@ impl Clone for RootCollectionPtr {
impl RootCollection {
/// Create an empty collection of roots
pub fn new() -> RootCollection {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
RootCollection {
roots: UnsafeCell::new(vec![]),
}
@@ -487,7 +487,7 @@ impl RootCollection {
/// Start tracking a stack-based root
fn root(&self, untracked_reflector: *const Reflector) {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
let mut roots = &mut *self.roots.get();
roots.push(untracked_reflector);
@@ -497,7 +497,7 @@ impl RootCollection {
/// Stop tracking a stack-based root, asserting if the reflector isn't found
fn unroot<T: Reflectable>(&self, rooted: &Root<T>) {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe {
let mut roots = &mut *self.roots.get();
let old_reflector = &*rooted.reflector();
@@ -562,7 +562,7 @@ impl<T: Reflectable> Root<T> {
/// It cannot not outlive its associated `RootCollection`, and it gives
/// out references which cannot outlive this new `Root`.
pub fn new(unrooted: NonZero<*const T>) -> Root<T> {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
STACK_ROOTS.with(|ref collection| {
let RootCollectionPtr(collection) = collection.get().unwrap();
unsafe { (*collection).root(&*(**unrooted).reflector()) }
@@ -588,7 +588,7 @@ impl<T: Reflectable> Root<T> {
impl<T: Reflectable> Deref for Root<T> {
type Target = T;
fn deref(&self) -> &T {
- debug_assert!(task_state::get().is_script());
+ debug_assert!(thread_state::get().is_script());
unsafe { &**self.ptr.deref() }
}
}