Skip to content

Commit c1d0751

Browse files
committed
Auto merge of #50699 - Zoxc:blocking-queries, r=<try>
WIP: Blocking Rayon queries r? @michaelwoerister
2 parents ac5c084 + 7e9d43f commit c1d0751

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+818
-170
lines changed

src/Cargo.lock

+13-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/builder.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl<'a> Builder<'a> {
334334
native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
335335
Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend,
336336
check::Rustdoc),
337-
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
337+
Kind::Test => describe!(test::Tidy, test::Bootstrap/*, test::Ui, test::RunPass,
338338
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
339339
test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,
340340
test::UiFullDeps, test::RunPassFullDeps, test::RunFailFullDeps,
@@ -347,8 +347,9 @@ impl<'a> Builder<'a> {
347347
test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample,
348348
test::TheBook, test::UnstableBook, test::RustcBook,
349349
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
350+
test::RustdocUi,
350351
// Run run-make last, since these won't pass without make on Windows
351-
test::RunMake, test::RustdocUi),
352+
test::RunMake*/),
352353
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
353354
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
354355
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,

src/bootstrap/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl Config {
531531
set(&mut config.test_miri, rust.test_miri);
532532
set(&mut config.wasm_syscall, rust.wasm_syscall);
533533
set(&mut config.lld_enabled, rust.lld);
534-
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
534+
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(true);
535535
config.rustc_default_linker = rust.default_linker.clone();
536536
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
537537
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);

src/libproc_macro/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#![feature(lang_items)]
3939
#![feature(optin_builtin_traits)]
4040

41+
#![recursion_limit="256"]
42+
4143
extern crate syntax;
4244
extern crate syntax_pos;
4345
extern crate rustc_errors;

src/librustc/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ fmt_macros = { path = "../libfmt_macros" }
1515
graphviz = { path = "../libgraphviz" }
1616
jobserver = "0.1"
1717
lazy_static = "1.0.0"
18+
scoped-tls = { version = "0.1.1", features = ["nightly"] }
1819
log = { version = "0.4", features = ["release_max_level_info", "std"] }
1920
proc_macro = { path = "../libproc_macro" }
21+
rustc-rayon-core = { git = "https://github.com/Zoxc/rayon.git", branch = "rustc" }
22+
rustc-rayon = { git = "https://github.com/Zoxc/rayon.git", branch = "rustc" }
2023
rustc_apfloat = { path = "../librustc_apfloat" }
2124
rustc_target = { path = "../librustc_target" }
2225
rustc_data_structures = { path = "../librustc_data_structures" }
@@ -25,6 +28,7 @@ serialize = { path = "../libserialize" }
2528
syntax = { path = "../libsyntax" }
2629
syntax_pos = { path = "../libsyntax_pos" }
2730
backtrace = "0.3.3"
31+
parking_lot = "0.5.5"
2832
byteorder = { version = "1.1", features = ["i128"]}
2933

3034
# Note that these dependencies are a lie, they're just here to get linkage to

src/librustc/hir/itemlikevisit.rs

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ pub trait IntoVisitor<'hir> {
101101
fn into_visitor(&self) -> Self::Visitor;
102102
}
103103

104+
#[derive(Clone)]
105+
pub struct ClonableVisitor<V>(pub V);
106+
107+
impl<'hir, V: Visitor<'hir> + Clone> IntoVisitor<'hir> for ClonableVisitor<V> {
108+
type Visitor = V;
109+
110+
fn into_visitor(&self) -> V {
111+
self.clone().0
112+
}
113+
}
114+
104115
pub struct ParDeepVisitor<V>(pub V);
105116

106117
impl<'hir, V> ParItemLikeVisitor<'hir> for ParDeepVisitor<V>

src/librustc/hir/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,13 @@ impl Crate {
746746
});
747747
}
748748

749+
pub fn par_deep_visit_items<'hir, V>(&'hir self, visitor: V)
750+
where V: intravisit::Visitor<'hir> + Clone + Sync + Send
751+
{
752+
let visitor = itemlikevisit::ClonableVisitor(visitor);
753+
self.par_visit_all_item_likes(&itemlikevisit::ParDeepVisitor(visitor));
754+
}
755+
749756
pub fn body(&self, id: BodyId) -> &Body {
750757
&self.bodies[&id]
751758
}

src/librustc/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
4141
html_root_url = "https://doc.rust-lang.org/nightly/")]
4242

43+
#![feature(attr_literals)]
4344
#![feature(box_patterns)]
4445
#![feature(box_syntax)]
4546
#![feature(const_fn)]
@@ -49,6 +50,7 @@
4950
#![cfg_attr(stage0, feature(dyn_trait))]
5051
#![feature(from_ref)]
5152
#![feature(fs_read_write)]
53+
#![feature(iterator_step_by)]
5254
#![cfg_attr(windows, feature(libc))]
5355
#![cfg_attr(stage0, feature(macro_lifetime_matcher))]
5456
#![feature(macro_vis_matcher)]
@@ -61,6 +63,7 @@
6163
#![feature(optin_builtin_traits)]
6264
#![feature(refcell_replace_swap)]
6365
#![feature(rustc_diagnostic_macros)]
66+
#![feature(set_stdio)]
6467
#![feature(slice_patterns)]
6568
#![feature(slice_sort_by_cached_key)]
6669
#![feature(specialization)]
@@ -70,6 +73,7 @@
7073
#![feature(catch_expr)]
7174
#![feature(test)]
7275
#![feature(inclusive_range_methods)]
76+
#![feature(vec_remove_item)]
7377

7478
#![recursion_limit="512"]
7579

@@ -80,12 +84,16 @@ extern crate fmt_macros;
8084
extern crate getopts;
8185
extern crate graphviz;
8286
#[macro_use] extern crate lazy_static;
87+
#[macro_use] extern crate scoped_tls;
8388
#[cfg(windows)]
8489
extern crate libc;
8590
extern crate rustc_target;
8691
#[macro_use] extern crate rustc_data_structures;
8792
extern crate serialize;
93+
extern crate parking_lot;
8894
extern crate rustc_errors as errors;
95+
extern crate rustc_rayon as rayon;
96+
extern crate rustc_rayon_core as rayon_core;
8997
#[macro_use] extern crate log;
9098
#[macro_use] extern crate syntax;
9199
extern crate syntax_pos;

src/librustc/middle/intrinsicck.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ use hir::intravisit::{self, Visitor, NestedVisitorMap};
1919
use hir;
2020

2121
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
22-
let mut visitor = ItemVisitor {
23-
tcx,
24-
};
25-
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
22+
tcx.hir.krate().par_deep_visit_items(ItemVisitor { tcx });
2623
}
2724

25+
#[derive(Clone)]
2826
struct ItemVisitor<'a, 'tcx: 'a> {
2927
tcx: TyCtxt<'a, 'tcx, 'tcx>
3028
}

src/librustc/middle/stability.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
324324
}
325325
}
326326

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

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

497+
#[derive(Clone)]
497498
struct Checker<'a, 'tcx: 'a> {
498499
tcx: TyCtxt<'a, 'tcx, 'tcx>,
499500
}
@@ -807,7 +808,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
807808
};
808809
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span);
809810
intravisit::walk_crate(&mut missing, krate);
810-
krate.visit_all_item_likes(&mut missing.as_deep_visitor());
811+
krate.par_deep_visit_items(missing);
811812
}
812813

813814
let ref declared_lib_features = tcx.features().declared_lib_features;

src/librustc/session/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,10 @@ impl Session {
845845
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
846846
/// This expends fuel if applicable, and records fuel if applicable.
847847
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
848-
assert!(self.query_threads() == 1);
849848
let mut ret = true;
850849
match self.optimization_fuel_crate {
851850
Some(ref c) if c == crate_name => {
851+
assert!(self.query_threads() == 1);
852852
let fuel = self.optimization_fuel_limit.get();
853853
ret = fuel != 0;
854854
if fuel == 0 && !self.out_of_fuel.get() {
@@ -862,6 +862,7 @@ impl Session {
862862
}
863863
match self.print_fuel_crate {
864864
Some(ref c) if c == crate_name => {
865+
assert!(self.query_threads() == 1);
865866
self.print_fuel.set(self.print_fuel.get() + 1);
866867
}
867868
_ => {}
@@ -871,8 +872,8 @@ impl Session {
871872

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

878879
/// Returns the number of query threads that should be used for this

src/librustc/traits/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use ty::error::{ExpectedFound, TypeError};
2828
use infer::{InferCtxt};
2929

3030
use rustc_data_structures::sync::Lrc;
31-
use std::rc::Rc;
3231
use syntax::ast;
3332
use syntax_pos::{Span, DUMMY_SP};
3433

@@ -254,7 +253,7 @@ pub struct DerivedObligationCause<'tcx> {
254253
parent_trait_ref: ty::PolyTraitRef<'tcx>,
255254

256255
/// The parent trait had this cause
257-
parent_code: Rc<ObligationCauseCode<'tcx>>
256+
parent_code: Lrc<ObligationCauseCode<'tcx>>
258257
}
259258

260259
pub type Obligations<'tcx, O> = Vec<Obligation<'tcx, O>>;

src/librustc/traits/select.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ use ty::relate::TypeRelation;
4444
use middle::lang_items;
4545
use mir::interpret::{GlobalId};
4646

47-
use rustc_data_structures::sync::Lock;
47+
use rustc_data_structures::sync::{Lrc, Lock};
4848
use rustc_data_structures::bitvec::BitVector;
4949
use std::iter;
5050
use std::cmp;
5151
use std::fmt;
5252
use std::mem;
53-
use std::rc::Rc;
5453
use rustc_target::spec::abi::Abi;
5554
use hir;
5655
use util::nodemap::{FxHashMap, FxHashSet};
@@ -3400,7 +3399,7 @@ impl<'tcx> TraitObligation<'tcx> {
34003399
if obligation.recursion_depth >= 0 {
34013400
let derived_cause = DerivedObligationCause {
34023401
parent_trait_ref: obligation.predicate.to_poly_trait_ref(),
3403-
parent_code: Rc::new(obligation.cause.code.clone())
3402+
parent_code: Lrc::new(obligation.cause.code.clone())
34043403
};
34053404
let derived_code = variant(derived_cause);
34063405
ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code)

src/librustc/traits/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ty::{self, Lift, TyCtxt};
1515
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
1616

1717
use std::fmt;
18-
use std::rc::Rc;
18+
use rustc_data_structures::sync::Lrc;
1919

2020
// structural impls for the structs in traits
2121

@@ -254,7 +254,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> {
254254
tcx.lift(&*self.parent_code).map(|code| {
255255
traits::DerivedObligationCause {
256256
parent_trait_ref: trait_ref,
257-
parent_code: Rc::new(code)
257+
parent_code: Lrc::new(code)
258258
}
259259
})
260260
})

0 commit comments

Comments
 (0)