Skip to content

Commit

Permalink
Auto merge of #19872 - nox:domrefcell-tracing, r=jdm
Browse files Browse the repository at this point in the history
Make JSTraceable for DomRefCell<T> panic if cell is mutably borrowed

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19872)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jan 26, 2018
2 parents 4f17235 + 31a1408 commit c0d9f28
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 0 additions & 12 deletions components/script/dom/bindings/cell.rs
Expand Up @@ -29,18 +29,6 @@ impl<T> DomRefCell<T> {
&*self.value.as_ptr()
}

/// 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!
#[allow(unsafe_code)]
pub unsafe fn borrow_for_gc_trace(&self) -> &T {
// FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs
// https://github.com/servo/servo/issues/6389
// debug_assert!(thread_state::get().contains(SCRIPT | IN_GC));
&*self.value.as_ptr()
}

/// Borrow the contents for the purpose of script deallocation.
///
#[allow(unsafe_code)]
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/trace.rs
Expand Up @@ -206,7 +206,7 @@ unsafe impl<T: JSTraceable> JSTraceable for UnsafeCell<T> {

unsafe impl<T: JSTraceable> JSTraceable for DomRefCell<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
(*self).borrow_for_gc_trace().trace(trc)
(*self).borrow().trace(trc)
}
}

Expand Down

0 comments on commit c0d9f28

Please sign in to comment.