aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/cell.rs
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2014-10-23 18:10:00 -0700
committerKeegan McAllister <kmcallister@mozilla.com>2014-10-24 16:27:37 -0700
commit49234484d6539a4d8df8374a9548c2004b8e68b7 (patch)
treef08c75e46b6ccf17c93ad2142410b11b0ad35bb6 /components/script/dom/bindings/cell.rs
parent6ec0939a2248e0e092242076ed5b2cd2486c736c (diff)
downloadservo-49234484d6539a4d8df8374a9548c2004b8e68b7.tar.gz
servo-49234484d6539a4d8df8374a9548c2004b8e68b7.zip
Ignore the HTML parser's borrow flag in GC tracing
Adds some other dynamic checks in debug builds.
Diffstat (limited to 'components/script/dom/bindings/cell.rs')
-rw-r--r--components/script/dom/bindings/cell.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs
index 4aa993fec45..f15e829c87b 100644
--- a/components/script/dom/bindings/cell.rs
+++ b/components/script/dom/bindings/cell.rs
@@ -6,6 +6,7 @@ use dom::bindings::trace::JSTraceable;
use js::jsapi::{JSTracer};
use servo_util::task_state;
+use servo_util::task_state::{Script, InGC};
use std::cell::{Cell, UnsafeCell};
use std::kinds::marker;
@@ -33,6 +34,23 @@ impl<T> DOMRefCell<T> {
&*self.value.get()
}
+ /// Borrow the contents for the purpose of GC tracing.
+ ///
+ /// This succeeds even if the object is mutably borrowed,
+ /// so you have to be careful in trace code!
+ pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T {
+ debug_assert!(task_state::get().contains(Script | InGC));
+ &*self.value.get()
+ }
+
+ /// Is the cell mutably borrowed?
+ ///
+ /// For safety checks in debug builds only.
+ #[cfg(not(ndebug))]
+ pub fn is_mutably_borrowed(&self) -> bool {
+ self.borrow.get() == WRITING
+ }
+
pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> {
debug_assert!(task_state::get().is_script());
match self.borrow.get() {