Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.

This commit is contained in:
Ms2ger 2015-01-02 12:45:28 +01:00 committed by Josh Matthews
parent cf616b90a2
commit 16c7060bc8
153 changed files with 2095 additions and 1298 deletions

View file

@ -21,6 +21,9 @@ use servo_util::opts;
use servo_util::tid::tid;
use style::TNode;
use std::cell::RefCell;
use std::mem;
/// Every time we do another layout, the old bloom filters are invalid. This is
/// detected by ticking a generation number every layout.
type Generation = uint;
@ -45,7 +48,7 @@ type Generation = uint;
/// Since a work-stealing queue is used for styling, sometimes, the bloom filter
/// will no longer be the for the parent of the node we're currently on. When
/// this happens, the task local bloom filter will be thrown away and rebuilt.
local_data_key!(style_bloom: (Box<BloomFilter>, UnsafeLayoutNode, Generation))
thread_local!(static STYLE_BLOOM: RefCell<Option<(Box<BloomFilter>, UnsafeLayoutNode, Generation)>> = RefCell::new(None))
/// Returns the task local bloom filter.
///
@ -53,43 +56,48 @@ local_data_key!(style_bloom: (Box<BloomFilter>, UnsafeLayoutNode, Generation))
/// it will be thrown out and a new one will be made for you.
fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context: &LayoutContext)
-> Box<BloomFilter> {
match (parent_node, style_bloom.replace(None)) {
// Root node. Needs new bloom filter.
(None, _ ) => {
debug!("[{}] No parent, but new bloom filter!", tid());
box BloomFilter::new()
}
// No bloom filter for this thread yet.
(Some(parent), None) => {
let mut bloom_filter = box BloomFilter::new();
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context);
bloom_filter
}
// Found cached bloom filter.
(Some(parent), Some((mut bloom_filter, old_node, old_generation))) => {
// Hey, the cached parent is our parent! We can reuse the bloom filter.
if old_node == layout_node_to_unsafe_layout_node(&parent) &&
old_generation == layout_context.shared.generation {
debug!("[{}] Parent matches (={}). Reusing bloom filter.", tid(), old_node.val0());
bloom_filter
} else {
// Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing
// allocation to avoid malloc churn.
*bloom_filter = BloomFilter::new();
STYLE_BLOOM.with(|style_bloom| {
match (parent_node, style_bloom.borrow_mut().take()) {
// Root node. Needs new bloom filter.
(None, _ ) => {
debug!("[{}] No parent, but new bloom filter!", tid());
box BloomFilter::new()
}
// No bloom filter for this thread yet.
(Some(parent), None) => {
let mut bloom_filter = box BloomFilter::new();
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context);
bloom_filter
}
},
}
// Found cached bloom filter.
(Some(parent), Some((mut bloom_filter, old_node, old_generation))) => {
// Hey, the cached parent is our parent! We can reuse the bloom filter.
if old_node == layout_node_to_unsafe_layout_node(&parent) &&
old_generation == layout_context.shared.generation {
debug!("[{}] Parent matches (={}). Reusing bloom filter.", tid(), old_node.val0());
bloom_filter.clone()
} else {
// Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing
// allocation to avoid malloc churn.
*bloom_filter = BloomFilter::new();
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context);
bloom_filter
}
},
}
})
}
fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
unsafe_node: &UnsafeLayoutNode,
layout_context: &LayoutContext) {
match style_bloom.replace(Some((bf, *unsafe_node, layout_context.shared.generation))) {
None => {},
Some(_) => panic!("Putting into a never-taken task-local bloom filter"),
}
let bf: *mut BloomFilter = unsafe { mem::transmute(bf) };
STYLE_BLOOM.with(|style_bloom| {
assert!(style_bloom.borrow().is_none(),
"Putting into a never-taken task-local bloom filter");
let bf: Box<BloomFilter> = unsafe { mem::transmute(bf) };
*style_bloom.borrow_mut() = Some((bf, *unsafe_node, layout_context.shared.generation));
})
}
/// "Ancestors" in this context is inclusive of ourselves.
@ -112,6 +120,7 @@ fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>,
/// The recalc-style-for-node traversal, which styles each node and must run before
/// layout computation. This computes the styles applied to each node.
#[deriving(Copy)]
pub struct RecalcStyleForNode<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
@ -200,6 +209,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
}
/// The flow construction traversal, which builds flows for styled nodes.
#[deriving(Copy)]
pub struct ConstructFlows<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
@ -238,9 +248,10 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> {
let unsafe_layout_node = layout_node_to_unsafe_layout_node(&node);
let (mut bf, old_node, old_generation) =
style_bloom
.replace(None)
.expect("The bloom filter should have been set by style recalc.");
STYLE_BLOOM.with(|style_bloom| {
mem::replace(&mut *style_bloom.borrow_mut(), None)
.expect("The bloom filter should have been set by style recalc.")
});
assert_eq!(old_node, unsafe_layout_node);
assert_eq!(old_generation, self.layout_context.shared.generation);
@ -297,6 +308,7 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> {
}
/// The assign-inline-sizes traversal. In Gecko this corresponds to `Reflow`.
#[deriving(Copy)]
pub struct AssignISizes<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
@ -317,6 +329,7 @@ impl<'a> PreorderFlowTraversal for AssignISizes<'a> {
/// layout computation. Determines the final block-sizes for all layout objects, computes
/// positions, and computes overflow regions. In Gecko this corresponds to `Reflow` and
/// `FinishAndStoreOverflow`.
#[deriving(Copy)]
pub struct AssignBSizesAndStoreOverflow<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
@ -341,6 +354,7 @@ impl<'a> PostorderFlowTraversal for AssignBSizesAndStoreOverflow<'a> {
}
}
#[deriving(Copy)]
pub struct ComputeAbsolutePositions<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
@ -352,6 +366,7 @@ impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> {
}
}
#[deriving(Copy)]
pub struct BuildDisplayList<'a> {
pub layout_context: &'a LayoutContext<'a>,
}