Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Dec 10, 2017
1 parent 0128f64 commit fea3b26
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 58 deletions.
78 changes: 76 additions & 2 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/ty/maps/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}*/
}
}

Expand Down
38 changes: 0 additions & 38 deletions src/librustc/ty/maps/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -169,8 +168,6 @@ macro_rules! profq_key {
}
}

pub static QUERY_DEPTH: AtomicUsize = AtomicUsize::new(0);

macro_rules! define_maps {
(<$tcx:tt>
$($(#[$attr:meta])*
Expand All @@ -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! {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)]
{
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 4 additions & 12 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2098,17 +2098,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn par_body_owners<F: Fn(DefId) + Sync + Send>(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 {
Expand Down

0 comments on commit fea3b26

Please sign in to comment.