Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hoist bloom filter into scoped TLS, and remove a bunch of complexity and unsafety from the style system #14662

Merged
merged 5 commits into from Dec 22, 2016
Prev

Remove generation, remove filter pop, and add size tests.

  • Loading branch information
bholley committed Dec 22, 2016
commit 940cda1d15203063af00a5763e5ac090ddbd9c5a
@@ -112,7 +112,7 @@ pub trait PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode: ThreadSafeLayo
#[inline]
#[allow(unsafe_code)]
fn construct_flows_at<'a, N>(context: &LayoutContext<'a>,
thread_local: &mut ScopedThreadLocalLayoutContext<N::ConcreteElement>,
_thread_local: &mut ScopedThreadLocalLayoutContext<N::ConcreteElement>,
node: N)
where N: LayoutNode,
{
@@ -139,8 +139,6 @@ fn construct_flows_at<'a, N>(context: &LayoutContext<'a>,
if let Some(el) = node.as_element() {
el.mutate_data().unwrap().persist();
unsafe { el.unset_dirty_descendants(); }

thread_local.style_context.bloom_filter.maybe_pop(el);
}
}

@@ -520,7 +520,6 @@ impl LayoutThread {
viewport_size: self.viewport_size.clone(),
screen_size_changed: screen_size_changed,
stylist: rw_data.stylist.clone(),
generation: self.generation,
goal: goal,
running_animations: self.running_animations.clone(),
expired_animations: self.expired_animations.clone(),
@@ -19,7 +19,7 @@ pub mod size_of {
use dom::htmlspanelement::HTMLSpanElement;
use dom::node::Node;
use dom::text::Text;
use layout_wrapper::ServoThreadSafeLayoutNode;
use layout_wrapper::{ServoLayoutElement, ServoLayoutNode, ServoThreadSafeLayoutNode};
use std::mem::size_of;

pub fn CharacterData() -> usize {
@@ -50,6 +50,14 @@ pub mod size_of {
size_of::<Node>()
}

pub fn SendElement() -> usize {
size_of::<::style::dom::SendElement<ServoLayoutElement>>()
}

pub fn SendNode() -> usize {
size_of::<::style::dom::SendNode<ServoLayoutNode>>()
}

pub fn ServoThreadSafeLayoutNode() -> usize {
size_of::<ServoThreadSafeLayoutNode>()
}
@@ -49,10 +49,6 @@ pub struct SharedStyleContext {
/// The CSS selector stylist.
pub stylist: Arc<Stylist>,

/// Starts at zero, and increased by one every time a layout completes.
/// This can be used to easily check for invalid stale data.
pub generation: u32,

/// Why is this reflow occurring
pub goal: ReflowGoal,

@@ -25,9 +25,6 @@ pub struct PerDocumentStyleDataImpl {
/// Rule processor.
pub stylist: Arc<Stylist>,

/// Last restyle generation.
pub last_restyle_generation: u32,

/// List of stylesheets, mirrored from Gecko.
pub stylesheets: Vec<Arc<Stylesheet>>,

@@ -67,7 +64,6 @@ impl PerDocumentStyleData {

PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
stylist: Arc::new(Stylist::new(device)),
last_restyle_generation: 0,
stylesheets: vec![],
stylesheets_changed: true,
new_animations_sender: new_anims_sender,
@@ -105,12 +101,6 @@ impl PerDocumentStyleDataImpl {
self.stylesheets_changed = false;
}
}

pub fn next_generation(&mut self) -> u32 {
self.last_restyle_generation =
self.last_restyle_generation.wrapping_add(1);
self.last_restyle_generation
}
}

unsafe impl HasFFI for PerDocumentStyleData {
@@ -18,10 +18,6 @@ use std::mem;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use stylist::Stylist;

/// Every time we do another layout, the old bloom filters are invalid. This is
/// detected by ticking a generation number every layout.
pub type Generation = u32;

/// Style sharing candidate cache stats. These are only used when
/// `-Z style-sharing-stats` is given.
pub static STYLE_SHARING_CACHE_HITS: AtomicUsize = ATOMIC_USIZE_INIT;
@@ -101,7 +101,6 @@ fn create_shared_context(mut per_doc_data: &mut AtomicRefMut<PerDocumentStyleDat
// FIXME (bug 1303229): Use the actual viewport size here
viewport_size: Size2D::new(Au(0), Au(0)),
screen_size_changed: false,
generation: per_doc_data.next_generation(),
goal: ReflowGoal::ForScriptQuery,
stylist: per_doc_data.stylist.clone(),
running_animations: per_doc_data.running_animations.clone(),
@@ -38,3 +38,7 @@ sizeof_checker!(size_span, HTMLSpanElement, 336);
sizeof_checker!(size_text, Text, 184);
sizeof_checker!(size_characterdata, CharacterData, 184);
sizeof_checker!(size_servothreadsafelayoutnode, ServoThreadSafeLayoutNode, 16);

// We use these types in the parallel traversal. They should stay pointer-sized.
sizeof_checker!(size_sendelement, SendElement, 8);
sizeof_checker!(size_sendnode, SendNode, 8);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.