Skip to content
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

incr.comp.: Switch to red/green change tracking, remove legacy system. #44901

Merged
merged 12 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
17 changes: 3 additions & 14 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ use hir::{HirId, ItemLocalId};

use ich::Fingerprint;
use ty::{TyCtxt, Instance, InstanceDef};
use ty::fast_reject::SimplifiedType;
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
use ich::StableHashingContext;
use std::fmt;
Expand Down Expand Up @@ -430,7 +429,6 @@ define_dep_nodes!( <'tcx>
[] RegionScopeTree(DefId),
[] Coherence,
[] CoherenceInherentImplOverlapCheck,
[] Resolve,
[] CoherenceCheckTrait(DefId),
[] PrivacyAccessLevels(CrateNum),

Expand All @@ -447,10 +445,8 @@ define_dep_nodes!( <'tcx>
[] MirBorrowCheck(DefId),
[] UnsafetyViolations(DefId),

[] RvalueCheck(DefId),
[] Reachability,
[] MirKeys,
[] TransWriteMetadata,
[] CrateVariances,

// Nodes representing bits of computed IR in the tcx. Each shared
Expand Down Expand Up @@ -498,18 +494,9 @@ define_dep_nodes!( <'tcx>

// The set of impls for a given trait.
[] TraitImpls(DefId),
[] RelevantTraitImpls(DefId, SimplifiedType),

[] AllLocalTraitImpls,

// Nodes representing caches. To properly handle a true cache, we
// don't use a DepTrackingMap, but rather we push a task node.
// Otherwise the write into the map would be incorrectly
// attributed to the first task that happened to fill the cache,
// which would yield an overly conservative dep-graph.
[] TraitItems(DefId),
[] ReprHints(DefId),

// Trait selection cache is a little funny. Given a trait
// reference like `Foo: SomeTrait<Bar>`, there could be
// arbitrarily many def-ids to map on in there (e.g., `Foo`,
Expand Down Expand Up @@ -598,7 +585,6 @@ define_dep_nodes!( <'tcx>
[] MissingLangItems(CrateNum),
[] ExternConstBody(DefId),
[] VisibleParentMap,
[] IsDirectExternCrate(CrateNum),
[] MissingExternCrateItem(CrateNum),
[] UsedCrateSource(CrateNum),
[] PostorderCnums,
Expand All @@ -618,6 +604,9 @@ define_dep_nodes!( <'tcx>
[] CodegenUnit(InternedString),
[] CompileCodegenUnit(InternedString),
[] OutputFilenames,

// We use this for most things when incr. comp. is turned off.
[] Null,
);

trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
Expand Down
34 changes: 29 additions & 5 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,9 @@ impl DepGraph {

let mut current_deps = Vec::new();

for &dep_dep_node in prev_deps {
let dep_dep_node = &data.previous.index_to_node(dep_dep_node);
for &dep_dep_node_index in prev_deps {
let dep_dep_node = &data.previous.index_to_node(dep_dep_node_index);

let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => {
Expand All @@ -478,19 +479,42 @@ impl DepGraph {
return None
}
None => {
if dep_dep_node.kind.is_input() {
// This input does not exist anymore.
debug_assert!(dep_dep_node.extract_def_id(tcx).is_none());
return None;
}

// We don't know the state of this dependency. Let's try to
// mark it green.
if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) {
current_deps.push(node_index);
} else {
// We failed to mark it green. This can have various
// reasons.
return None
// We failed to mark it green, so we try to force the query.
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => {
current_deps.push(node_index);
}
Some(DepNodeColor::Red) => {
return None
}
None => {
bug!("try_mark_green() - Forcing the DepNode \
should have set its color")
}
}
} else {
// The DepNode could not be forced.
return None
}
}
}
}
}


// If we got here without hitting a `return` that means that all
// dependencies of this DepNode could be marked as green. Therefore we
// can also mark this DepNode as green. We do so by...
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use syntax::symbol::Symbol;
#[macro_use]
mod plumbing;
use self::plumbing::*;
pub use self::plumbing::force_from_dep_node;

mod keys;
pub use self::keys::Key;
Expand Down
Loading