about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2019-01-29 16:47:30 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2019-01-30 21:19:02 +0100
commit38bcd4b42a1d0a5546122e78efb266161aa4c731 (patch)
tree71af7251790abf71b5fa37fed4eada6af644771c /src/librustc_data_structures
parentd9a2e3b1ccf16c6d43f56f503bd80c1ad137d523 (diff)
downloadrust-38bcd4b42a1d0a5546122e78efb266161aa4c731.tar.gz
rust-38bcd4b42a1d0a5546122e78efb266161aa4c731.zip
Move privacy checking later in the pipeline and make some passes run in parallel
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/sync.rs27
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;