diff options
| author | bors <bors@rust-lang.org> | 2019-02-07 09:49:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-02-07 09:49:08 +0000 |
| commit | ad433894abd4231fb2102416a520ae995ee09aed (patch) | |
| tree | f240435aa4f2154ce259f6ff3cf31aee88e73f56 /src/librustc_data_structures | |
| parent | 626e74d5f64cdc820b6c6ac1a5a9a42096cd147a (diff) | |
| parent | 38bcd4b42a1d0a5546122e78efb266161aa4c731 (diff) | |
| download | rust-ad433894abd4231fb2102416a520ae995ee09aed.tar.gz rust-ad433894abd4231fb2102416a520ae995ee09aed.zip | |
Auto merge of #58010 - Zoxc:parallel-passes, r=michaelwoerister
Move privacy checking later in the pipeline and make some passes run in parallel r? @michaelwoerister
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/sync.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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: IntoIterator>(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; |
