diff --git a/src/Cargo.lock b/src/Cargo.lock index d210b9e1bfff0..5f0c124368746 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -71,6 +71,14 @@ dependencies = [ "rustc_data_structures 0.0.0", ] +[[package]] +name = "arrayvec" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.3" @@ -459,6 +467,44 @@ name = "crossbeam" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crossbeam-channel" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crossbeam-utils" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crypto-hash" version = "0.3.0" @@ -1142,6 +1188,11 @@ dependencies = [ "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memoffset" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "miniz-sys" version = "0.1.10" @@ -1189,6 +1240,11 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nodrop" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "num" version = "0.1.41" @@ -1340,6 +1396,15 @@ dependencies = [ "unwind 0.0.0", ] +[[package]] +name = "parking_lot" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot" version = "0.5.3" @@ -1514,7 +1579,7 @@ dependencies = [ [[package]] name = "rayon" version = "0.9.0" -source = "git+https://github.com/Zoxc/rayon.git?branch=fiber#8c9062f4f32b568f66ca372ba477a984a807bbaa" +source = "git+https://github.com/Zoxc/rayon.git?branch=fiber#bdfe9a08e11a257e1e4ea66142e170335174471f" dependencies = [ "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.3.0 (git+https://github.com/Zoxc/rayon.git?branch=fiber)", @@ -1532,10 +1597,11 @@ dependencies = [ [[package]] name = "rayon-core" version = "1.3.0" -source = "git+https://github.com/Zoxc/rayon.git?branch=fiber#8c9062f4f32b568f66ca372ba477a984a807bbaa" +source = "git+https://github.com/Zoxc/rayon.git?branch=fiber#bdfe9a08e11a257e1e4ea66142e170335174471f" dependencies = [ "coco 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "context 2.0.0 (git+https://github.com/Zoxc/context-rs.git)", + "crossbeam-channel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2818,6 +2884,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" "checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455" "checksum ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35c7a5669cb64f085739387e1308b74e6d44022464b7f1b63bbd4ceb6379ec31" +"checksum arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2f0ef4a9820019a0c91d918918c93dc71d469f581a49b47ddc1d285d4270bbe2" "checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" "checksum backtrace 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8709cc7ec06f6f0ae6c2c7e12f6ed41540781f72b488d83734978295ceae182e" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" @@ -2841,6 +2908,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5" "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" "checksum crossbeam 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8837ab96533202c5b610ed44bc7f4183e7957c1c8f56e8cc78bb098593c8ba0a" +"checksum crossbeam-channel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b22f46060fc413087047d89aea5d21d0615ecb07cb46183e8e9c7b81b9a00843" +"checksum crossbeam-epoch 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "207b3d14d81f66ac1219ac5d912880e6223009970e36a1bc3ab3b09e557ebfeb" +"checksum crossbeam-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48977ab703ec8c483018bb7e7377aabc8e4adbb96478e09d023b212c2ed4e6b1" +"checksum crossbeam-utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c8cdb001669f648a82afa7c16bab16f09978d10484c196ebc4b6e861a377ba7" "checksum crypto-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34903878eec1694faf53cae8473a088df333181de421d4d3d48061d6559fe602" "checksum cssparser 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef6124306e5ebc5ab11891d063aeafdd0cdc308079b708c8b566125f3680292b" "checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df" @@ -2908,10 +2979,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" +"checksum memoffset 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e163e5baece1a039e71e75b074de17a9b4114982aa109921fc20253bdf91a53c" "checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" +"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4083e14b542ea3eb9b5f33ff48bd373a92d78687e74f4cc0a30caeb754f0ca" "checksum num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "bdc1494b5912f088f260b775799468d9b9209ac60885d8186a547a0476289e23" "checksum num-complex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "58de7b4bf7cf5dbecb635a5797d489864eadd03b107930cbccf9e0fd7428b47c" @@ -2927,6 +3000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum os_pipe 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "998bfbb3042e715190fe2a41abfa047d7e8cb81374d2977d7f100eacd8619cb1" "checksum owning_ref 0.3.3 (git+https://github.com/Zoxc/owning-ref-rs.git)" = "" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" +"checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e7f7c9857874e54afeb950eebeae662b1e51a2493666d2ea4c0a5d91dcf0412" "checksum parking_lot_core 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6c677d78851950b3aec390e681a411f78cc250cba277d4f578758a377f727970" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 1f5df78aa4b75..5c1a24361f91f 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -16,7 +16,7 @@ graphviz = { path = "../libgraphviz" } jobserver = "0.1" log = "0.3" rayon = { git = "https://github.com/Zoxc/rayon.git", branch = "fiber" } -rayon-core = { git = "https://github.com/Zoxc/rayon.git", branch = "fiber", features=["debug", "tlv"] } +rayon-core = { git = "https://github.com/Zoxc/rayon.git", branch = "fiber", features=["tlv"] } scoped-tls = { git = "https://github.com/Zoxc/scoped-tls.git", features=["nightly"] } owning_ref = { git = "https://github.com/Zoxc/owning-ref-rs.git" } rustc_back = { path = "../librustc_back" } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 4734b6a1357db..0b4a12650f932 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -86,7 +86,6 @@ extern crate x86; extern crate owning_ref; extern crate rustc_back; #[macro_use] extern crate rustc_data_structures; -#[macro_use] extern crate lazy_static; extern crate serialize; extern crate rustc_const_math; extern crate rustc_errors as errors; diff --git a/src/librustc/ty/maps/job.rs b/src/librustc/ty/maps/job.rs index 2f1adeac639bf..a2716c4531c53 100644 --- a/src/librustc/ty/maps/job.rs +++ b/src/librustc/ty/maps/job.rs @@ -45,20 +45,20 @@ impl<'tcx> QueryJob<'tcx> { } pub fn await(&self) { - #[cfg(parallel_queries)] + /*#[cfg(parallel_queries)] registry::in_worker(|worker, _| { unsafe { worker.wait_until(&self.latch); } - }); + });*/ } pub fn signal_complete(&self) { - #[cfg(parallel_queries)] + /*#[cfg(parallel_queries)] { self.latch.set(); Registry::current().signal(); - } + }*/ } } diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index f96fa31a4169d..8ee8e12ef6d58 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -19,7 +19,6 @@ use ty::maps::Query; // NB: actually generated by the macros in this file use ty::maps::config::QueryDescription; use ty::maps::job::QueryResult; use ty::item_path; -use std::sync::atomic::AtomicUsize; use rustc_data_structures::fx::{FxHashMap}; use rustc_data_structures::sync::LockGuard; @@ -169,8 +168,6 @@ macro_rules! profq_key { } } -pub static QUERY_DEPTH: AtomicUsize = AtomicUsize::new(0); - macro_rules! define_maps { (<$tcx:tt> $($(#[$attr:meta])* @@ -182,8 +179,6 @@ macro_rules! define_maps { use std::mem; use std::panic; use errors::Diagnostic; - use ty::maps::plumbing::QUERY_DEPTH; - use std::sync::atomic::Ordering; use rayon_core; define_map_struct! { @@ -298,19 +293,6 @@ macro_rules! define_maps { } else { break }; - lazy_static! { - static ref LOG: bool = ::std::env::var("QUERY_LOG").is_ok(); - } - - if *LOG { - println!("({}) waiting on query {:?} latch {:x}", - QUERY_DEPTH.load(Ordering::SeqCst), - Query::$name(Clone::clone(&key)), &job.latch as *const _ as usize); - for i in tcx.query().stack.iter() { - println!(" query stack entry {:?}", i); - - } - } // If there is a cycle, waiting will never complete tcx.cycle_check(span, &Query::$name(Clone::clone(&key)))?; job.await(); @@ -441,25 +423,11 @@ macro_rules! define_maps { tcx.cycle_check(span, &query)?; - lazy_static! { - static ref LOG: bool = ::std::env::var("QUERY_LOG").is_ok(); - } - let entry = (span, query); let stack = tcx.query().stack.iter().cloned().chain(iter::once(entry)).collect(); let job = Lrc::new(QueryJob::new(stack, true, false)); job.start(); - if *LOG { - println!("({}) starting query {:?} latch {:x}", - QUERY_DEPTH.load(Ordering::SeqCst), - query.clone(), &job.latch as *const _ as usize); - for i in tcx.query().stack.iter() { - println!(" query stack entry {:?}", i); - - } - } - QUERY_DEPTH.fetch_add(1, Ordering::SeqCst); #[cfg(parallel_queries)] { @@ -501,12 +469,6 @@ macro_rules! define_maps { r }; - if *LOG { - println!("ending query {:?}", query.clone()); - } - - QUERY_DEPTH.fetch_sub(1, Ordering::SeqCst); - let diagnostics: Vec<_> = { let mut diagnostics = job.diagnostics.lock(); let diagnostics: Vec<_> = diagnostics.drain(..).collect(); diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index e395c37d9bdc0..9c8208a34cabb 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -42,7 +42,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; use std::iter::FromIterator; use std::ops::Deref; -use rustc_data_structures::sync::{Send, Sync, Lrc}; +use rustc_data_structures::sync::{par_iter, Send, Sync, Lrc}; use std::slice; use std::vec::IntoIter; use std::mem; @@ -2098,17 +2098,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn par_body_owners(self, f: F) { - #[cfg(not(parallel_queries))] - self.body_owners().for_each(|def_id| f(def_id)); - - #[cfg(parallel_queries)] - { - use rayon::prelude::*; - self.hir.krate() - .body_ids - .par_iter() - .for_each(|&body_id| f(self.hir.body_owner_def_id(body_id))); - } + par_iter(&self.hir.krate().body_ids).for_each(|&body_id| { + f(self.hir.body_owner_def_id(body_id)) + }); } pub fn expr_span(self, id: NodeId) -> Span {