style: Avoid dropping the other threads' TLS contexts too early.

When collecting style statistics, we have this path that moves the TLS contexts
to be dropped before the local context.

Since destroying the TLS context runs the sequential task queue, that means that
sequential tasks would be executed sooner than usual, before we drop the main
thread TLS context.

Since we have that reuse of the main thread context's bloom filter, and some
tasks end up creating one (Servo_StyleSet_GetBaseComputedValuesForElement, I'm
looking at you), we may borrow the bloom filter before we're done with it on the
traversal code path.

This was hitting on YouTube, when DUMP_STYLE_STATISTICS was used.
This commit is contained in:
Emilio Cobos Álvarez 2017-09-04 13:17:45 +02:00
parent 862f3b4369
commit 2d1b387a4c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -115,7 +115,7 @@ where
let mut aggregate =
mem::replace(&mut context.thread_local.statistics, Default::default());
let parallel = maybe_tls.is_some();
if let Some(tls) = maybe_tls {
if let Some(ref mut tls) = maybe_tls {
let slots = unsafe { tls.unsafe_get() };
aggregate = slots.iter().fold(aggregate, |acc, t| {
match *t.borrow() {