Introduce and use Scoped TLS.

It turns out that it's problematic to embed ThreadLocalStyleContext within
LayoutContext, because parameterizing the former on TElement (which we do
in the next patch) infects all the traversal stuff with the trait parameters,
which we don't really want.

In general, it probably makes sense to use separate scoped TLS types for
the separate DOM and Flow tree passes, so we can add a different ScopedTLS
type for the Flow pass if we ever need it.

We also reorder the |scope| and |shared| parameters in parallel.rs, because
it aligns more with the order in style/parallel.rs. I did this when I was
adding a TLS parameter to all these functions, which I realized we don't need
for now.
This commit is contained in:
Bobby Holley 2016-12-16 11:50:11 -08:00
parent 8f7f62f810
commit c5f01fe3b8
16 changed files with 212 additions and 205 deletions

View file

@ -63,7 +63,8 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use layout::animation;
use layout::construct::ConstructionResult;
use layout::context::{LayoutContext, SharedLayoutContext, ThreadLocalLayoutContext, heap_size_of_local_context};
use layout::context::{LayoutContext, SharedLayoutContext};
use layout::context::heap_size_of_persistent_local_context;
use layout::display_list_builder::ToGfxColor;
use layout::flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
use layout::flow_ref::FlowRef;
@ -723,11 +724,11 @@ impl LayoutThread {
size: stylist.heap_size_of_children(),
});
// The LayoutThread has a context in TLS...
// The LayoutThread has data in Persistent TLS...
reports.push(Report {
path: path![formatted_url, "layout-thread", "local-context"],
kind: ReportKind::ExplicitJemallocHeapSize,
size: heap_size_of_local_context(),
size: heap_size_of_persistent_local_context(),
});
reports_chan.send(reports);
@ -1447,8 +1448,7 @@ impl LayoutThread {
self.profiler_metadata(),
self.time_profiler_chan.clone(),
|| {
let tlc = ThreadLocalLayoutContext::new(&shared);
let context = LayoutContext::new(&shared, &*tlc);
let context = LayoutContext::new(&shared);
sequential::store_overflow(&context,
FlowRef::deref_mut(&mut root_flow) as &mut Flow);
});