summaryrefslogtreecommitdiffstats
path: root/servo/components/style/driver.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /servo/components/style/driver.rs
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/components/style/driver.rs')
-rw-r--r--servo/components/style/driver.rs42
1 files changed, 25 insertions, 17 deletions
diff --git a/servo/components/style/driver.rs b/servo/components/style/driver.rs
index 95447ce08e..a2407cb209 100644
--- a/servo/components/style/driver.rs
+++ b/servo/components/style/driver.rs
@@ -46,16 +46,28 @@ fn report_statistics(stats: &PerThreadTraversalStatistics) {
gecko_stats.mStylesReused += stats.styles_reused;
}
-fn with_pool_in_place_scope<'scope, R>(
+fn with_pool_in_place_scope<'scope>(
work_unit_max: usize,
pool: Option<&rayon::ThreadPool>,
- closure: impl FnOnce(Option<&rayon::ScopeFifo<'scope>>) -> R,
-) -> R {
+ closure: impl FnOnce(Option<&rayon::ScopeFifo<'scope>>) + Send + 'scope,
+) {
if work_unit_max == 0 || pool.is_none() {
- closure(None)
+ closure(None);
} else {
- pool.unwrap()
- .in_place_scope_fifo(|scope| closure(Some(scope)))
+ let pool = pool.unwrap();
+ pool.in_place_scope_fifo(|scope| {
+ #[cfg(feature = "gecko")]
+ debug_assert_eq!(
+ pool.current_thread_index(),
+ Some(0),
+ "Main thread should be the first thread"
+ );
+ if cfg!(feature = "gecko") || pool.current_thread_index().is_some() {
+ closure(Some(scope));
+ } else {
+ scope.spawn_fifo(|scope| closure(Some(scope)));
+ }
+ });
}
}
@@ -108,6 +120,8 @@ where
// Process the nodes breadth-first. This helps keep similar traversal characteristics for the
// style sharing cache.
let work_unit_max = work_unit_max();
+
+ let send_root = unsafe { SendNode::new(root.as_node()) };
with_pool_in_place_scope(work_unit_max, pool, |maybe_scope| {
let mut tlc = scoped_tls.ensure(parallel::create_thread_local_context);
let mut context = StyleContext {
@@ -115,22 +129,16 @@ where
thread_local: &mut tlc,
};
- debug_assert_eq!(
- scoped_tls.current_thread_index(),
- 0,
- "Main thread should be the first thread"
- );
-
let mut discovered = VecDeque::with_capacity(work_unit_max * 2);
- discovered.push_back(unsafe { SendNode::new(root.as_node()) });
+ let current_dom_depth = send_root.depth();
+ let opaque_root = send_root.opaque();
+ discovered.push_back(send_root);
parallel::style_trees(
&mut context,
discovered,
- root.as_node().opaque(),
+ opaque_root,
work_unit_max,
- PerLevelTraversalData {
- current_dom_depth: root.depth(),
- },
+ PerLevelTraversalData { current_dom_depth },
maybe_scope,
traversal,
&scoped_tls,