Skip to content

Commit

Permalink
Auto merge of #50699 - Zoxc:blocking-queries, r=<try>
Browse files Browse the repository at this point in the history
WIP: Blocking Rayon queries

r? @michaelwoerister
  • Loading branch information
bors committed May 15, 2018
2 parents ac5c084 + 7e9d43f commit c1d0751
Show file tree
Hide file tree
Showing 59 changed files with 818 additions and 170 deletions.
21 changes: 13 additions & 8 deletions src/Cargo.lock

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

5 changes: 3 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl<'a> Builder<'a> {
native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend,
check::Rustdoc),
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
Kind::Test => describe!(test::Tidy, test::Bootstrap/*, test::Ui, test::RunPass,
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,
test::UiFullDeps, test::RunPassFullDeps, test::RunFailFullDeps,
Expand All @@ -347,8 +347,9 @@ impl<'a> Builder<'a> {
test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample,
test::TheBook, test::UnstableBook, test::RustcBook,
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
test::RustdocUi,
// Run run-make last, since these won't pass without make on Windows
test::RunMake, test::RustdocUi),
test::RunMake*/),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl Config {
set(&mut config.test_miri, rust.test_miri);
set(&mut config.wasm_syscall, rust.wasm_syscall);
set(&mut config.lld_enabled, rust.lld);
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(true);
config.rustc_default_linker = rust.default_linker.clone();
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
Expand Down
2 changes: 2 additions & 0 deletions src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#![feature(lang_items)]
#![feature(optin_builtin_traits)]

#![recursion_limit="256"]

extern crate syntax;
extern crate syntax_pos;
extern crate rustc_errors;
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
lazy_static = "1.0.0"
scoped-tls = { version = "0.1.1", features = ["nightly"] }
log = { version = "0.4", features = ["release_max_level_info", "std"] }
proc_macro = { path = "../libproc_macro" }
rustc-rayon-core = { git = "https://github.com/Zoxc/rayon.git", branch = "rustc" }
rustc-rayon = { git = "https://github.com/Zoxc/rayon.git", branch = "rustc" }
rustc_apfloat = { path = "../librustc_apfloat" }
rustc_target = { path = "../librustc_target" }
rustc_data_structures = { path = "../librustc_data_structures" }
Expand All @@ -25,6 +28,7 @@ serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
parking_lot = "0.5.5"
byteorder = { version = "1.1", features = ["i128"]}

# Note that these dependencies are a lie, they're just here to get linkage to
Expand Down
11 changes: 11 additions & 0 deletions src/librustc/hir/itemlikevisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ pub trait IntoVisitor<'hir> {
fn into_visitor(&self) -> Self::Visitor;
}

#[derive(Clone)]
pub struct ClonableVisitor<V>(pub V);

impl<'hir, V: Visitor<'hir> + Clone> IntoVisitor<'hir> for ClonableVisitor<V> {
type Visitor = V;

fn into_visitor(&self) -> V {
self.clone().0
}
}

pub struct ParDeepVisitor<V>(pub V);

impl<'hir, V> ParItemLikeVisitor<'hir> for ParDeepVisitor<V>
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,13 @@ impl Crate {
});
}

pub fn par_deep_visit_items<'hir, V>(&'hir self, visitor: V)
where V: intravisit::Visitor<'hir> + Clone + Sync + Send
{
let visitor = itemlikevisit::ClonableVisitor(visitor);
self.par_visit_all_item_likes(&itemlikevisit::ParDeepVisitor(visitor));
}

pub fn body(&self, id: BodyId) -> &Body {
&self.bodies[&id]
}
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]

#![feature(attr_literals)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_fn)]
Expand All @@ -49,6 +50,7 @@
#![cfg_attr(stage0, feature(dyn_trait))]
#![feature(from_ref)]
#![feature(fs_read_write)]
#![feature(iterator_step_by)]
#![cfg_attr(windows, feature(libc))]
#![cfg_attr(stage0, feature(macro_lifetime_matcher))]
#![feature(macro_vis_matcher)]
Expand All @@ -61,6 +63,7 @@
#![feature(optin_builtin_traits)]
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]
#![feature(set_stdio)]
#![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)]
#![feature(specialization)]
Expand All @@ -70,6 +73,7 @@
#![feature(catch_expr)]
#![feature(test)]
#![feature(inclusive_range_methods)]
#![feature(vec_remove_item)]

#![recursion_limit="512"]

Expand All @@ -80,12 +84,16 @@ extern crate fmt_macros;
extern crate getopts;
extern crate graphviz;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate scoped_tls;
#[cfg(windows)]
extern crate libc;
extern crate rustc_target;
#[macro_use] extern crate rustc_data_structures;
extern crate serialize;
extern crate parking_lot;
extern crate rustc_errors as errors;
extern crate rustc_rayon as rayon;
extern crate rustc_rayon_core as rayon_core;
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_pos;
Expand Down
6 changes: 2 additions & 4 deletions src/librustc/middle/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
use hir;

pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut visitor = ItemVisitor {
tcx,
};
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
tcx.hir.krate().par_deep_visit_items(ItemVisitor { tcx });
}

#[derive(Clone)]
struct ItemVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>
}
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
}
}

#[derive(Clone)]
struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
access_levels: &'a AccessLevels,
Expand Down Expand Up @@ -466,8 +467,7 @@ impl<'a, 'tcx> Index<'tcx> {
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors.
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut checker = Checker { tcx: tcx };
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
tcx.hir.krate().par_deep_visit_items(Checker { tcx: tcx });
}

/// Check whether an item marked with `deprecated(since="X")` is currently
Expand All @@ -494,6 +494,7 @@ pub fn deprecation_in_effect(since: &str) -> bool {
}
}

#[derive(Clone)]
struct Checker<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
Expand Down Expand Up @@ -807,7 +808,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
};
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span);
intravisit::walk_crate(&mut missing, krate);
krate.visit_all_item_likes(&mut missing.as_deep_visitor());
krate.par_deep_visit_items(missing);
}

let ref declared_lib_features = tcx.features().declared_lib_features;
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,10 @@ impl Session {
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
/// This expends fuel if applicable, and records fuel if applicable.
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
assert!(self.query_threads() == 1);
let mut ret = true;
match self.optimization_fuel_crate {
Some(ref c) if c == crate_name => {
assert!(self.query_threads() == 1);
let fuel = self.optimization_fuel_limit.get();
ret = fuel != 0;
if fuel == 0 && !self.out_of_fuel.get() {
Expand All @@ -862,6 +862,7 @@ impl Session {
}
match self.print_fuel_crate {
Some(ref c) if c == crate_name => {
assert!(self.query_threads() == 1);
self.print_fuel.set(self.print_fuel.get() + 1);
}
_ => {}
Expand All @@ -871,8 +872,8 @@ impl Session {

/// Returns the number of query threads that should be used for this
/// compilation
pub fn query_threads_from_opts(opts: &config::Options) -> usize {
opts.debugging_opts.query_threads.unwrap_or(1)
pub fn query_threads_from_opts(_opts: &config::Options) -> usize {
/*opts.debugging_opts.query_threads.unwrap_or(1)*/8
}

/// Returns the number of query threads that should be used for this
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use ty::error::{ExpectedFound, TypeError};
use infer::{InferCtxt};

use rustc_data_structures::sync::Lrc;
use std::rc::Rc;
use syntax::ast;
use syntax_pos::{Span, DUMMY_SP};

Expand Down Expand Up @@ -254,7 +253,7 @@ pub struct DerivedObligationCause<'tcx> {
parent_trait_ref: ty::PolyTraitRef<'tcx>,

/// The parent trait had this cause
parent_code: Rc<ObligationCauseCode<'tcx>>
parent_code: Lrc<ObligationCauseCode<'tcx>>
}

pub type Obligations<'tcx, O> = Vec<Obligation<'tcx, O>>;
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ use ty::relate::TypeRelation;
use middle::lang_items;
use mir::interpret::{GlobalId};

use rustc_data_structures::sync::Lock;
use rustc_data_structures::sync::{Lrc, Lock};
use rustc_data_structures::bitvec::BitVector;
use std::iter;
use std::cmp;
use std::fmt;
use std::mem;
use std::rc::Rc;
use rustc_target::spec::abi::Abi;
use hir;
use util::nodemap::{FxHashMap, FxHashSet};
Expand Down Expand Up @@ -3400,7 +3399,7 @@ impl<'tcx> TraitObligation<'tcx> {
if obligation.recursion_depth >= 0 {
let derived_cause = DerivedObligationCause {
parent_trait_ref: obligation.predicate.to_poly_trait_ref(),
parent_code: Rc::new(obligation.cause.code.clone())
parent_code: Lrc::new(obligation.cause.code.clone())
};
let derived_code = variant(derived_cause);
ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ty::{self, Lift, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};

use std::fmt;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;

// structural impls for the structs in traits

Expand Down Expand Up @@ -254,7 +254,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> {
tcx.lift(&*self.parent_code).map(|code| {
traits::DerivedObligationCause {
parent_trait_ref: trait_ref,
parent_code: Rc::new(code)
parent_code: Lrc::new(code)
}
})
})
Expand Down
Loading

0 comments on commit c1d0751

Please sign in to comment.