summaryrefslogtreecommitdiffstats
path: root/servo/components/style/bloom.rs
diff options
context:
space:
mode:
Diffstat (limited to 'servo/components/style/bloom.rs')
-rw-r--r--servo/components/style/bloom.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/servo/components/style/bloom.rs b/servo/components/style/bloom.rs
index 63be881505..a5f47d8b41 100644
--- a/servo/components/style/bloom.rs
+++ b/servo/components/style/bloom.rs
@@ -10,11 +10,8 @@
use crate::dom::{SendElement, TElement};
use crate::LocalName;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
-use owning_ref::OwningHandle;
use selectors::bloom::BloomFilter;
-use servo_arc::Arc;
use smallvec::SmallVec;
-use std::mem::ManuallyDrop;
thread_local! {
/// Bloom filters are large allocations, so we store them in thread-local storage
@@ -24,10 +21,12 @@ thread_local! {
/// We intentionally leak this from TLS because we don't have the guarantee
/// of TLS destructors to run in worker threads.
///
+ /// Also, leaking it guarantees that we can borrow it indefinitely.
+ ///
/// We could change this once https://github.com/rayon-rs/rayon/issues/688
- /// is fixed, hopefully.
- static BLOOM_KEY: ManuallyDrop<Arc<AtomicRefCell<BloomFilter>>> =
- ManuallyDrop::new(Arc::new_leaked(Default::default()));
+ /// is fixed, hopefully, which point we'd need to change the filter member below to be an
+ /// arc and carry an owning reference around or so.
+ static BLOOM_KEY: &'static AtomicRefCell<BloomFilter> = Box::leak(Default::default());
}
/// A struct that allows us to fast-reject deep descendant selectors avoiding
@@ -66,7 +65,7 @@ pub struct StyleBloom<E: TElement> {
/// was created. We use AtomicRefCell so that this is all |Send|, which allows
/// StyleBloom to live in ThreadLocalStyleContext, which is dropped from the
/// parent thread.
- filter: OwningHandle<Arc<AtomicRefCell<BloomFilter>>, AtomicRefMut<'static, BloomFilter>>,
+ filter: AtomicRefMut<'static, BloomFilter>,
/// The stack of elements that this bloom filter contains, along with the
/// number of hashes pushed for each element.
@@ -152,9 +151,7 @@ impl<E: TElement> StyleBloom<E> {
// See https://github.com/servo/servo/pull/18420#issuecomment-328769322
#[inline(never)]
pub fn new() -> Self {
- let bloom_arc = BLOOM_KEY.with(|b| Arc::clone(&*b));
- let filter =
- OwningHandle::new_with_fn(bloom_arc, |x| unsafe { x.as_ref() }.unwrap().borrow_mut());
+ let filter = BLOOM_KEY.with(|b| b.borrow_mut());
debug_assert!(
filter.is_zeroed(),
"Forgot to zero the bloom filter last time"