Skip to content

Rollup of 18 pull requests #50611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
May 11, 2018
Merged
Changes from 3 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5ab4c81
str/slice: factor out overflow error messages
ExpHP Apr 30, 2018
6b749b0
Clean up the other Slice*Inclusive impls for str
ExpHP Apr 30, 2018
4fab167
update libcore's comment about str tests
ExpHP Apr 30, 2018
0842dc6
collect str SliceIndex tests into a mod
ExpHP Apr 30, 2018
ce66f5d
flesh out tests for SliceIndex
ExpHP Apr 30, 2018
02b3da1
decrease false negatives for str overflow test
ExpHP Apr 30, 2018
030aa9b
revise macro in slice tests
ExpHP Apr 30, 2018
f1d7b45
revise test gen macro for str
ExpHP Apr 30, 2018
b0fcb5f
Extend tests for RFC1598 (GAT)
gavento Mar 27, 2018
e09d9ec
Tidy up the code
gavento Mar 27, 2018
a66a011
Fix test stderr after tidying the source
gavento Mar 28, 2018
0617b92
Add tests for GAT parameter number and kindness
gavento Mar 28, 2018
571337b
Update tests with Nikos comments
gavento Apr 11, 2018
a43171a
Update tests to use compile-pass
gavento May 2, 2018
9073c89
Minor fromatting for RFC 1598 tests
gavento May 2, 2018
000d3c9
Make DepGraph::previous_work_products immutable
wesleywiser May 8, 2018
ea49428
Don't use Lock for heavily accessed CrateMetadata::cnum_map.
michaelwoerister May 8, 2018
868d2a1
Fix comment
wesleywiser May 8, 2018
5128aff
Fix update-references for tests within subdirectories.
ehuss May 4, 2018
31d2012
Adapt some method visibilities in librustc_metadata::cstore.
michaelwoerister May 8, 2018
77c40f8
Inline `Span` methods.
nnethercote May 9, 2018
78262e7
Use SmallVec for DepNodeIndex within dep_graph.
nnethercote May 9, 2018
0ba1c10
Clarify in the docs that `mul_add` is not always faster.
frewsxcv May 9, 2018
b8b957d
Make CrateNum allocation more thread-safe.
michaelwoerister May 8, 2018
a981089
Allow for specifying a linker plugin for cross-language LTO
michaelwoerister Apr 25, 2018
23aa483
add fn `into_inner(self) -> (Idx, Idx)` to RangeInclusive (#49022)
May 9, 2018
254b601
std: Avoid `ptr::copy` if unnecessary in `vec::Drain`
alexcrichton May 9, 2018
4537025
Add comment about first element in CStore::metas.
michaelwoerister May 9, 2018
8010604
move See also links to top
ExpHP May 9, 2018
b8eb91a
make std::str link into See also link
ExpHP May 9, 2018
9c4e5b3
Restore RawVec::reserve* documentation
glandium May 10, 2018
ae3feff
Remove unnecessary mutable borrow and resizing
whitfin May 10, 2018
7def3f0
Retry when downloading the Docker cache.
kennytm May 10, 2018
12446dd
Pull in a wasm fix from LLVM upstream
alexcrichton May 7, 2018
85f5738
Fix tuple struct field spans
estebank May 9, 2018
ecd9898
Rollup merge of #49423 - gavento:gavento-dev, r=nikomatsakis
alexcrichton May 10, 2018
cff1a26
Rollup merge of #50010 - ExpHP:slice-bounds, r=alexcrichton
alexcrichton May 10, 2018
7bd4fda
Rollup merge of #50447 - ehuss:fix-update-references, r=alexcrichton
alexcrichton May 10, 2018
4c4396c
Rollup merge of #50514 - alexcrichton:update-llvm, r=kennytm
alexcrichton May 10, 2018
bb130ce
Rollup merge of #50524 - wesleywiser:immutable_prev_work_products, r=…
alexcrichton May 10, 2018
296f952
Rollup merge of #50532 - michaelwoerister:lockless-cnum-map, r=Zoxc
alexcrichton May 10, 2018
4199a6c
Rollup merge of #50538 - michaelwoerister:atomic-cnums, r=Zoxc
alexcrichton May 10, 2018
a77ba86
Rollup merge of #50564 - nnethercote:inline-Span-methods, r=petrochenkov
alexcrichton May 10, 2018
e23ec4b
Rollup merge of #50565 - nnethercote:try_mark_green, r=michaelwoerister
alexcrichton May 10, 2018
dd40277
Rollup merge of #50569 - michaelwoerister:cross-lang-lto-2, r=alexcri…
alexcrichton May 10, 2018
be6fab8
Rollup merge of #50572 - frewsxcv:frewsxcv-fma, r=sfackler
alexcrichton May 10, 2018
445e53e
Rollup merge of #50574 - s3bk:range_inclusive_into_inner, r=SimonSapin
alexcrichton May 10, 2018
44f8b4d
Rollup merge of #50575 - alexcrichton:faster-drain-drop, r=sfackler
alexcrichton May 10, 2018
c798cbb
Rollup merge of #50588 - ExpHP:i-can-see-my-house-from-here, r=frewsxcv
alexcrichton May 10, 2018
1f1c65d
Rollup merge of #50590 - estebank:off-by-one, r=nikomatsakis
alexcrichton May 10, 2018
8b5f692
Rollup merge of #50591 - glandium:cleanup, r=dtolnay
alexcrichton May 10, 2018
74e731f
Rollup merge of #50598 - whitfin:unnecessary-mut-borrow, r=michaelwoe…
alexcrichton May 10, 2018
694ba9c
Rollup merge of #50606 - kennytm:retry-docker-cache, r=alexcrichton
alexcrichton May 10, 2018
2c5d13d
Skip a memory-hungry test that OOMs
alexcrichton May 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ struct DepGraphData {
/// things available to us. If we find that they are not dirty, we
/// load the path to the file storing those work-products here into
/// this map. We can later look for and extract that data.
previous_work_products: RwLock<FxHashMap<WorkProductId, WorkProduct>>,
previous_work_products: FxHashMap<WorkProductId, WorkProduct>,

/// Work-products that we generate in this run.
work_products: RwLock<FxHashMap<WorkProductId, WorkProduct>>,
@@ -90,7 +90,8 @@ struct DepGraphData {

impl DepGraph {

pub fn new(prev_graph: PreviousDepGraph) -> DepGraph {
pub fn new(prev_graph: PreviousDepGraph,
prev_work_products: FxHashMap<WorkProductId, WorkProduct>) -> DepGraph {
// Pre-allocate the fingerprints array. We over-allocate a little so
// that we hopefully don't have to re-allocate during this compilation
// session.
@@ -100,7 +101,7 @@ impl DepGraph {
(prev_graph_node_count * 115) / 100);
DepGraph {
data: Some(Lrc::new(DepGraphData {
previous_work_products: RwLock::new(FxHashMap()),
previous_work_products: prev_work_products,
work_products: RwLock::new(FxHashMap()),
dep_node_debug: Lock::new(FxHashMap()),
current: Lock::new(CurrentDepGraph::new()),
@@ -460,19 +461,6 @@ impl DepGraph {
self.data.as_ref().unwrap().previous.node_to_index(dep_node)
}

/// Indicates that a previous work product exists for `v`. This is
/// invoked during initial start-up based on what nodes are clean
/// (and what files exist in the incr. directory).
pub fn insert_previous_work_product(&self, v: &WorkProductId, data: WorkProduct) {
debug!("insert_previous_work_product({:?}, {:?})", v, data);
self.data
.as_ref()
.unwrap()
.previous_work_products
.borrow_mut()
.insert(v.clone(), data);
}

/// Indicates that we created the given work-product in this run
/// for `v`. This record will be preserved and loaded in the next
/// run.
@@ -492,7 +480,7 @@ impl DepGraph {
self.data
.as_ref()
.and_then(|data| {
data.previous_work_products.borrow().get(v).cloned()
data.previous_work_products.get(v).cloned()
})
}

@@ -504,8 +492,8 @@ impl DepGraph {

/// Access the map of work-products created during the cached run. Only
/// used during saving of the dep-graph.
pub fn previous_work_products(&self) -> ReadGuard<FxHashMap<WorkProductId, WorkProduct>> {
self.data.as_ref().unwrap().previous_work_products.borrow()
pub fn previous_work_products(&self) -> &FxHashMap<WorkProductId, WorkProduct> {
&self.data.as_ref().unwrap().previous_work_products
}

#[inline(always)]
19 changes: 10 additions & 9 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
@@ -980,15 +980,16 @@ where
let dep_graph = match future_dep_graph {
None => DepGraph::new_disabled(),
Some(future) => {
let prev_graph = time(sess, "blocked while dep-graph loading finishes", || {
future
.open()
.unwrap_or_else(|e| rustc_incremental::LoadResult::Error {
message: format!("could not decode incremental cache: {:?}", e),
})
.open(sess)
});
DepGraph::new(prev_graph)
let (prev_graph, prev_work_products) =
time(sess, "blocked while dep-graph loading finishes", || {
future
.open()
.unwrap_or_else(|e| rustc_incremental::LoadResult::Error {
message: format!("could not decode incremental cache: {:?}", e),
})
.open(sess)
});
DepGraph::new(prev_graph, prev_work_products)
}
};
let hir_forest = time(sess, "lowering ast -> hir", || {
112 changes: 57 additions & 55 deletions src/librustc_incremental/persist/load.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@

//! Code to save/load the dep-graph from files.

use rustc::dep_graph::{PreviousDepGraph, SerializedDepGraph};
use rustc_data_structures::fx::FxHashMap;
use rustc::dep_graph::{PreviousDepGraph, SerializedDepGraph, WorkProduct, WorkProductId};
use rustc::session::Session;
use rustc::ty::TyCtxt;
use rustc::ty::maps::OnDiskCache;
@@ -32,73 +33,30 @@ pub fn dep_graph_tcx_init<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {

tcx.allocate_metadata_dep_nodes();
tcx.precompute_in_scope_traits_hashes();

if tcx.sess.incr_comp_session_dir_opt().is_none() {
// If we are only building with -Zquery-dep-graph but without an actual
// incr. comp. session directory, we exit here. Otherwise we'd fail
// when trying to load work products.
return
}

let work_products_path = work_products_path(tcx.sess);
let load_result = load_data(tcx.sess.opts.debugging_opts.incremental_info, &work_products_path);

if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
// Decode the list of work_products
let mut work_product_decoder = Decoder::new(&work_products_data[..], start_pos);
let work_products: Vec<SerializedWorkProduct> =
RustcDecodable::decode(&mut work_product_decoder).unwrap_or_else(|e| {
let msg = format!("Error decoding `work-products` from incremental \
compilation session directory: {}", e);
tcx.sess.fatal(&msg[..])
});

for swp in work_products {
let mut all_files_exist = true;
for &(_, ref file_name) in swp.work_product.saved_files.iter() {
let path = in_incr_comp_dir_sess(tcx.sess, file_name);
if !path.exists() {
all_files_exist = false;

if tcx.sess.opts.debugging_opts.incremental_info {
eprintln!("incremental: could not find file for work \
product: {}", path.display());
}
}
}

if all_files_exist {
debug!("reconcile_work_products: all files for {:?} exist", swp);
tcx.dep_graph.insert_previous_work_product(&swp.id, swp.work_product);
} else {
debug!("reconcile_work_products: some file for {:?} does not exist", swp);
delete_dirty_work_product(tcx, swp);
}
}
}
}

type WorkProductMap = FxHashMap<WorkProductId, WorkProduct>;

pub enum LoadResult<T> {
Ok { data: T },
DataOutOfDate,
Error { message: String },
}


impl LoadResult<PreviousDepGraph> {
pub fn open(self, sess: &Session) -> PreviousDepGraph {
impl LoadResult<(PreviousDepGraph, WorkProductMap)> {
pub fn open(self, sess: &Session) -> (PreviousDepGraph, WorkProductMap) {
match self {
LoadResult::Error { message } => {
sess.warn(&message);
PreviousDepGraph::new(SerializedDepGraph::new())
(PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap())
},
LoadResult::DataOutOfDate => {
if let Err(err) = delete_all_session_dir_contents(sess) {
sess.err(&format!("Failed to delete invalidated or incompatible \
incremental compilation session directory contents `{}`: {}.",
dep_graph_path(sess).display(), err));
}
PreviousDepGraph::new(SerializedDepGraph::new())
(PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap())
}
LoadResult::Ok { data } => data
}
@@ -125,10 +83,10 @@ fn load_data(report_incremental_info: bool, path: &Path) -> LoadResult<(Vec<u8>,
}
}

fn delete_dirty_work_product(tcx: TyCtxt,
fn delete_dirty_work_product(sess: &Session,
swp: SerializedWorkProduct) {
debug!("delete_dirty_work_product({:?})", swp);
work_product::delete_workproduct_files(tcx.sess, &swp.work_product);
work_product::delete_workproduct_files(sess, &swp.work_product);
}

/// Either a result that has already be computed or a
@@ -149,7 +107,7 @@ impl<T> MaybeAsync<T> {

/// Launch a thread and load the dependency graph in the background.
pub fn load_dep_graph(sess: &Session) ->
MaybeAsync<LoadResult<PreviousDepGraph>>
MaybeAsync<LoadResult<(PreviousDepGraph, WorkProductMap)>>
{
// Since `sess` isn't `Sync`, we perform all accesses to `sess`
// before we fire the background thread.
@@ -159,7 +117,7 @@ pub fn load_dep_graph(sess: &Session) ->
if sess.opts.incremental.is_none() {
// No incremental compilation.
return MaybeAsync::Sync(LoadResult::Ok {
data: PreviousDepGraph::new(SerializedDepGraph::new())
data: (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap())
});
}

@@ -169,6 +127,50 @@ pub fn load_dep_graph(sess: &Session) ->
let report_incremental_info = sess.opts.debugging_opts.incremental_info;
let expected_hash = sess.opts.dep_tracking_hash();

let mut prev_work_products = FxHashMap();

// If we are only building with -Zquery-dep-graph but without an actual
// incr. comp. session directory, we skip this. Otherwise we'd fail
// when trying to load work products.
if sess.incr_comp_session_dir_opt().is_some() {
let work_products_path = work_products_path(sess);
let load_result = load_data(report_incremental_info, &work_products_path);

if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
// Decode the list of work_products
let mut work_product_decoder = Decoder::new(&work_products_data[..], start_pos);
let work_products: Vec<SerializedWorkProduct> =
RustcDecodable::decode(&mut work_product_decoder).unwrap_or_else(|e| {
let msg = format!("Error decoding `work-products` from incremental \
compilation session directory: {}", e);
sess.fatal(&msg[..])
});

for swp in work_products {
let mut all_files_exist = true;
for &(_, ref file_name) in swp.work_product.saved_files.iter() {
let path = in_incr_comp_dir_sess(sess, file_name);
if !path.exists() {
all_files_exist = false;

if sess.opts.debugging_opts.incremental_info {
eprintln!("incremental: could not find file for work \
product: {}", path.display());
}
}
}

if all_files_exist {
debug!("reconcile_work_products: all files for {:?} exist", swp);
prev_work_products.insert(swp.id, swp.work_product);
} else {
debug!("reconcile_work_products: some file for {:?} does not exist", swp);
delete_dirty_work_product(sess, swp);
}
}
}
}

MaybeAsync::Async(std::thread::spawn(move || {
time_ext(time_passes, None, "background load prev dep-graph", move || {
match load_data(report_incremental_info, &path) {
@@ -195,7 +197,7 @@ pub fn load_dep_graph(sess: &Session) ->
let dep_graph = SerializedDepGraph::decode(&mut decoder)
.expect("Error reading cached dep-graph");

LoadResult::Ok { data: PreviousDepGraph::new(dep_graph) }
LoadResult::Ok { data: (PreviousDepGraph::new(dep_graph), prev_work_products) }
}
}
})