From 38bcd4b42a1d0a5546122e78efb266161aa4c731 Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Tue, 29 Jan 2019 16:47:30 +0100 Subject: Move privacy checking later in the pipeline and make some passes run in parallel --- src/librustc_data_structures/sync.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/librustc_data_structures') diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index cae3087fe58..7fef1f374d6 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -127,6 +127,13 @@ cfg_if! { pub use self::serial_join as join; pub use self::serial_scope as scope; + #[macro_export] + macro_rules! parallel { + ($($blocks:tt),*) => { + $($blocks)*; + } + } + pub use std::iter::Iterator as ParallelIterator; pub fn par_iter(t: T) -> T::IntoIter { @@ -271,6 +278,26 @@ cfg_if! { use std::thread; pub use rayon::{join, scope}; + #[macro_export] + macro_rules! parallel { + (impl [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => { + parallel!(impl [$block, $($c,)*] [$($rest),*]) + }; + (impl [$($blocks:tt,)*] []) => { + ::rustc_data_structures::sync::scope(|s| { + $( + s.spawn(|_| $blocks); + )* + }) + }; + ($($blocks:tt),*) => { + // Reverse the order of the blocks since Rayon executes them in reverse order + // when using a single thread. This ensures the execution order matches that + // of a single threaded rustc + parallel!(impl [] [$($blocks),*]); + }; + } + pub use rayon_core::WorkerLocal; pub use rayon::iter::ParallelIterator; -- cgit 1.4.1-3-g733a5