mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
style: Add refcount logging to servo_arc.
Differential Revision: https://phabricator.services.mozilla.com/D32173
This commit is contained in:
parent
57868f571f
commit
9a9a4e12d5
10 changed files with 100 additions and 23 deletions
|
@ -19,7 +19,7 @@ thread_local! {
|
|||
/// such that they can be reused across style traversals. StyleBloom is responsible
|
||||
/// for ensuring that the bloom filter is zeroed when it is dropped.
|
||||
static BLOOM_KEY: Arc<AtomicRefCell<BloomFilter>> =
|
||||
Arc::new(AtomicRefCell::new(BloomFilter::new()));
|
||||
Arc::new_leaked(AtomicRefCell::new(BloomFilter::new()));
|
||||
}
|
||||
|
||||
/// A struct that allows us to fast-reject deep descendant selectors avoiding
|
||||
|
|
|
@ -1736,7 +1736,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
PropertyDeclaration::TextAlign(SpecifiedTextAlign::MozCenterOrInherit),
|
||||
Importance::Normal,
|
||||
);
|
||||
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
||||
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
|
||||
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
|
||||
};
|
||||
static ref TABLE_COLOR_RULE: ApplicableDeclarationBlock = {
|
||||
|
@ -1745,7 +1745,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
PropertyDeclaration::Color(SpecifiedColor(Color::InheritFromBodyQuirk.into())),
|
||||
Importance::Normal,
|
||||
);
|
||||
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
||||
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
|
||||
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
|
||||
};
|
||||
static ref MATHML_LANG_RULE: ApplicableDeclarationBlock = {
|
||||
|
@ -1754,7 +1754,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
PropertyDeclaration::XLang(SpecifiedLang(atom!("x-math"))),
|
||||
Importance::Normal,
|
||||
);
|
||||
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
||||
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
|
||||
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
|
||||
};
|
||||
static ref SVG_TEXT_DISABLE_ZOOM_RULE: ApplicableDeclarationBlock = {
|
||||
|
@ -1763,7 +1763,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
PropertyDeclaration::XTextZoom(SpecifiedZoom(false)),
|
||||
Importance::Normal,
|
||||
);
|
||||
let arc = Arc::new(global_style_data.shared_lock.wrap(pdb));
|
||||
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
|
||||
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints)
|
||||
};
|
||||
};
|
||||
|
|
|
@ -125,7 +125,7 @@ lazy_static! {
|
|||
};
|
||||
/// Global style data
|
||||
pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = GlobalStyleData {
|
||||
shared_lock: SharedRwLock::new(),
|
||||
shared_lock: SharedRwLock::new_leaked(),
|
||||
options: StyleSystemOptions::default(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -755,8 +755,7 @@ unsafe impl Sync for RuleTree {}
|
|||
unsafe impl Send for RuleTree {}
|
||||
|
||||
// On Gecko builds, hook into the leak checking machinery.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(debug_assertions)]
|
||||
#[cfg(all(feature = "gecko", debug_assertions))]
|
||||
mod gecko_leak_checking {
|
||||
use super::RuleNode;
|
||||
use std::mem::size_of;
|
||||
|
@ -789,15 +788,13 @@ mod gecko_leak_checking {
|
|||
|
||||
#[inline(always)]
|
||||
fn log_new(_ptr: *const RuleNode) {
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(debug_assertions)]
|
||||
#[cfg(all(feature = "gecko", debug_assertions))]
|
||||
gecko_leak_checking::log_ctor(_ptr);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn log_drop(_ptr: *const RuleNode) {
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg(debug_assertions)]
|
||||
#[cfg(all(feature = "gecko", debug_assertions))]
|
||||
gecko_leak_checking::log_dtor(_ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,14 @@ impl SharedRwLock {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new global shared lock (gecko).
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn new_leaked() -> Self {
|
||||
SharedRwLock {
|
||||
cell: Some(Arc::new_leaked(AtomicRefCell::new(SomethingZeroSizedButTyped))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new read-only shared lock (gecko).
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn read_only() -> Self {
|
||||
|
|
|
@ -485,8 +485,12 @@ type SharingCache<E> = SharingCacheBase<StyleSharingCandidate<E>>;
|
|||
type TypelessSharingCache = SharingCacheBase<FakeCandidate>;
|
||||
type StoredSharingCache = Arc<AtomicRefCell<TypelessSharingCache>>;
|
||||
|
||||
thread_local!(static SHARING_CACHE_KEY: StoredSharingCache =
|
||||
Arc::new(AtomicRefCell::new(TypelessSharingCache::default())));
|
||||
thread_local! {
|
||||
// TODO(emilio): Looks like a few of these should just be Rc<RefCell<>> or
|
||||
// something. No need for atomics in the thread-local code.
|
||||
static SHARING_CACHE_KEY: StoredSharingCache =
|
||||
Arc::new_leaked(AtomicRefCell::new(TypelessSharingCache::default()));
|
||||
}
|
||||
|
||||
/// An LRU cache of the last few nodes seen, so that we can aggressively try to
|
||||
/// reuse their styles.
|
||||
|
|
|
@ -10,7 +10,7 @@ pub use crate::values::specified::list::MozListReversed;
|
|||
pub use crate::values::specified::list::{QuotePair, Quotes};
|
||||
|
||||
lazy_static! {
|
||||
static ref INITIAL_QUOTES: crate::ArcSlice<QuotePair> = crate::ArcSlice::from_iter(
|
||||
static ref INITIAL_QUOTES: crate::ArcSlice<QuotePair> = crate::ArcSlice::from_iter_leaked(
|
||||
vec![
|
||||
QuotePair {
|
||||
opening: "\u{201c}".to_owned().into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue