From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- servo/components/style/sharing/mod.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'servo/components/style/sharing/mod.rs') diff --git a/servo/components/style/sharing/mod.rs b/servo/components/style/sharing/mod.rs index 28592a02c5..2b66db5530 100644 --- a/servo/components/style/sharing/mod.rs +++ b/servo/components/style/sharing/mod.rs @@ -76,13 +76,11 @@ use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles}; use crate::stylist::Stylist; use crate::values::AtomIdent; use atomic_refcell::{AtomicRefCell, AtomicRefMut}; -use owning_ref::OwningHandle; use selectors::matching::{NeedsSelectorFlags, SelectorCaches, VisitedHandlingMode}; -use servo_arc::Arc; use smallbitvec::SmallBitVec; use smallvec::SmallVec; use std::marker::PhantomData; -use std::mem::{self, ManuallyDrop}; +use std::mem; use std::ops::Deref; use std::ptr::NonNull; use uluru::LRUCache; @@ -535,12 +533,11 @@ impl SharingCache { /// [2] https://github.com/rust-lang/rust/issues/13707 type SharingCache = SharingCacheBase>; type TypelessSharingCache = SharingCacheBase; -type StoredSharingCache = Arc>; thread_local! { // See the comment on bloom.rs about why do we leak this. - static SHARING_CACHE_KEY: ManuallyDrop = - ManuallyDrop::new(Arc::new_leaked(Default::default())); + static SHARING_CACHE_KEY: &'static AtomicRefCell = + Box::leak(Default::default()); } /// An LRU cache of the last few nodes seen, so that we can aggressively try to @@ -550,7 +547,7 @@ thread_local! { /// storing nodes here temporarily is safe. pub struct StyleSharingCache { /// The LRU cache, with the type cast away to allow persisting the allocation. - cache_typeless: OwningHandle>, + cache_typeless: AtomicRefMut<'static, TypelessSharingCache>, /// Bind this structure to the lifetime of E, since that's what we effectively store. marker: PhantomData>, /// The DOM depth we're currently at. This is used as an optimization to @@ -593,9 +590,7 @@ impl StyleSharingCache { mem::align_of::>(), mem::align_of::() ); - let cache_arc = SHARING_CACHE_KEY.with(|c| Arc::clone(&*c)); - let cache = - OwningHandle::new_with_fn(cache_arc, |x| unsafe { x.as_ref() }.unwrap().borrow_mut()); + let cache = SHARING_CACHE_KEY.with(|c| c.borrow_mut()); debug_assert!(cache.is_empty()); StyleSharingCache { -- cgit v1.2.3