diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /servo/components/style/bloom.rs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/components/style/bloom.rs')
-rw-r--r-- | servo/components/style/bloom.rs | 17 |
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" |