Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a14045

Browse files
committedMay 18, 2016
Auto merge of #33476 - nikomatsakis:incr-comp-xcrate, r=mw
track incr. comp. dependencies across crates This PR refactors the compiler's incremental compilation hashing so that it can track dependencies across crates. The main bits are: - computing a hash representing the metadata for an item we are emitting - we do this by making `MetaData(X)` be the current task while computing metadata for an item - this naturally registers reads from any tables and things that we read for that purpose - we can then hash all the inputs to those tables - tracking when we access metadata - we do this by registering a read of `MetaData(X)` for each foreign item `X` whose metadata we read - hashing metadata from foreign items - we do this by loading up metadata from a file in the incr. comp. directory - if there is no file, we use the SVH for the entire crate There is one very simple test only at this point. The next PR will be focused on expanding out the tests. Note that this is based on top of rust-lang/rust#33228 r? @michaelwoerister
2 parents 9743c66 + f860f8b commit 9a14045

File tree

52 files changed

+1037
-370
lines changed

Some content is hidden

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

52 files changed

+1037
-370
lines changed
 

‎src/librustc/cfg/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl CFG {
6464
}
6565

6666
pub fn node_is_reachable(&self, id: ast::NodeId) -> bool {
67-
self.graph.depth_traverse(self.entry)
67+
self.graph.depth_traverse(self.entry, graph::OUTGOING)
6868
.any(|idx| self.graph.node_data(idx).id() == id)
6969
}
7070
}

‎src/librustc/dep_graph/debug.rs‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Code for debugging the dep-graph.
12+
13+
use super::dep_node::DepNode;
14+
use std::error::Error;
15+
use std::fmt::Debug;
16+
17+
/// A dep-node filter goes from a user-defined string to a query over
18+
/// nodes. Right now the format is like this:
19+
///
20+
/// x & y & z
21+
///
22+
/// where the format-string of the dep-node must contain `x`, `y`, and
23+
/// `z`.
24+
#[derive(Debug)]
25+
pub struct DepNodeFilter {
26+
text: String
27+
}
28+
29+
impl DepNodeFilter {
30+
pub fn new(text: &str) -> Self {
31+
DepNodeFilter {
32+
text: text.trim().to_string()
33+
}
34+
}
35+
36+
/// True if all nodes always pass the filter.
37+
pub fn accepts_all(&self) -> bool {
38+
self.text.is_empty()
39+
}
40+
41+
/// Tests whether `node` meets the filter, returning true if so.
42+
pub fn test<D: Clone + Debug>(&self, node: &DepNode<D>) -> bool {
43+
let debug_str = format!("{:?}", node);
44+
self.text.split("&")
45+
.map(|s| s.trim())
46+
.all(|f| debug_str.contains(f))
47+
}
48+
}
49+
50+
/// A filter like `F -> G` where `F` and `G` are valid dep-node
51+
/// filters. This can be used to test the source/target independently.
52+
pub struct EdgeFilter {
53+
pub source: DepNodeFilter,
54+
pub target: DepNodeFilter,
55+
}
56+
57+
impl EdgeFilter {
58+
pub fn new(test: &str) -> Result<EdgeFilter, Box<Error>> {
59+
let parts: Vec<_> = test.split("->").collect();
60+
if parts.len() != 2 {
61+
Err(format!("expected a filter like `a&b -> c&d`, not `{}`", test).into())
62+
} else {
63+
Ok(EdgeFilter {
64+
source: DepNodeFilter::new(parts[0]),
65+
target: DepNodeFilter::new(parts[1]),
66+
})
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)
Please sign in to comment.