1
Fork 0

incr.comp.: Add some logging to DepGraph::try_mark_green().

This commit is contained in:
Michael Woerister 2017-09-27 18:42:31 +02:00
parent e1994bd27b
commit c9a17ef174
2 changed files with 32 additions and 4 deletions

View file

@ -347,7 +347,7 @@ impl fmt::Debug for DepNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.kind)?; write!(f, "{:?}", self.kind)?;
if !self.kind.has_params() { if !self.kind.has_params() && !self.kind.is_anon() {
return Ok(()); return Ok(());
} }
@ -356,14 +356,14 @@ impl fmt::Debug for DepNode {
::ty::tls::with_opt(|opt_tcx| { ::ty::tls::with_opt(|opt_tcx| {
if let Some(tcx) = opt_tcx { if let Some(tcx) = opt_tcx {
if let Some(def_id) = self.extract_def_id(tcx) { if let Some(def_id) = self.extract_def_id(tcx) {
write!(f, "{}", tcx.item_path_str(def_id))?; write!(f, "{}", tcx.def_path(def_id).to_string(tcx))?;
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) { } else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) {
write!(f, "{}", s)?; write!(f, "{}", s)?;
} else { } else {
write!(f, "{:?}", self.hash)?; write!(f, "{}", self.hash)?;
} }
} else { } else {
write!(f, "{:?}", self.hash)?; write!(f, "{}", self.hash)?;
} }
Ok(()) Ok(())
})?; })?;

View file

@ -429,6 +429,7 @@ impl DepGraph {
tcx: TyCtxt, tcx: TyCtxt,
dep_node: &DepNode) dep_node: &DepNode)
-> Option<DepNodeIndex> { -> Option<DepNodeIndex> {
debug!("try_mark_green({:?}) - BEGIN", dep_node);
let data = self.data.as_ref().unwrap(); let data = self.data.as_ref().unwrap();
debug_assert!(!data.colors.borrow().contains_key(dep_node)); debug_assert!(!data.colors.borrow().contains_key(dep_node));
@ -440,6 +441,7 @@ impl DepGraph {
// eagerly marked as either red/green before any queries are // eagerly marked as either red/green before any queries are
// executed. // executed.
debug_assert!(dep_node.extract_def_id(tcx).is_none()); debug_assert!(dep_node.extract_def_id(tcx).is_none());
debug!("try_mark_green({:?}) - END - DepNode is deleted input", dep_node);
return None; return None;
} }
@ -454,6 +456,8 @@ impl DepGraph {
None => { None => {
// This DepNode did not exist in the previous compilation session, // This DepNode did not exist in the previous compilation session,
// so we cannot mark it as green. // so we cannot mark it as green.
debug!("try_mark_green({:?}) - END - DepNode does not exist in \
current compilation session anymore", dep_node);
return None return None
} }
}; };
@ -469,6 +473,8 @@ impl DepGraph {
// This dependency has been marked as green before, we are // This dependency has been marked as green before, we are
// still fine and can continue with checking the other // still fine and can continue with checking the other
// dependencies. // dependencies.
debug!("try_mark_green({:?}) --- found dependency {:?} to \
be immediately green", dep_node, dep_dep_node);
current_deps.push(node_index); current_deps.push(node_index);
} }
Some(DepNodeColor::Red) => { Some(DepNodeColor::Red) => {
@ -476,28 +482,47 @@ impl DepGraph {
// compared to the previous compilation session. We cannot // compared to the previous compilation session. We cannot
// mark the DepNode as green and also don't need to bother // mark the DepNode as green and also don't need to bother
// with checking any of the other dependencies. // with checking any of the other dependencies.
debug!("try_mark_green({:?}) - END - dependency {:?} was \
immediately red", dep_node, dep_dep_node);
return None return None
} }
None => { None => {
if dep_dep_node.kind.is_input() { if dep_dep_node.kind.is_input() {
// This input does not exist anymore. // This input does not exist anymore.
debug_assert!(dep_dep_node.extract_def_id(tcx).is_none()); debug_assert!(dep_dep_node.extract_def_id(tcx).is_none());
debug!("try_mark_green({:?}) - END - dependency {:?} \
was deleted input", dep_node, dep_dep_node);
return None; return None;
} }
debug!("try_mark_green({:?}) --- state of dependency {:?} \
is unknown, trying to mark it green", dep_node,
dep_dep_node);
// We don't know the state of this dependency. Let's try to // We don't know the state of this dependency. Let's try to
// mark it green. // mark it green.
if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) { if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) {
debug!("try_mark_green({:?}) --- managed to MARK \
dependency {:?} as green", dep_node, dep_dep_node);
current_deps.push(node_index); current_deps.push(node_index);
} else { } else {
// We failed to mark it green, so we try to force the query. // We failed to mark it green, so we try to force the query.
debug!("try_mark_green({:?}) --- trying to force \
dependency {:?}", dep_node, dep_dep_node);
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) { if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned(); let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
match dep_dep_node_color { match dep_dep_node_color {
Some(DepNodeColor::Green(node_index)) => { Some(DepNodeColor::Green(node_index)) => {
debug!("try_mark_green({:?}) --- managed to \
FORCE dependency {:?} to green",
dep_node, dep_dep_node);
current_deps.push(node_index); current_deps.push(node_index);
} }
Some(DepNodeColor::Red) => { Some(DepNodeColor::Red) => {
debug!("try_mark_green({:?}) - END - \
dependency {:?} was red after forcing",
dep_node,
dep_dep_node);
return None return None
} }
None => { None => {
@ -507,6 +532,8 @@ impl DepGraph {
} }
} else { } else {
// The DepNode could not be forced. // The DepNode could not be forced.
debug!("try_mark_green({:?}) - END - dependency {:?} \
could not be forced", dep_node, dep_dep_node);
return None return None
} }
} }
@ -553,6 +580,7 @@ impl DepGraph {
.insert(*dep_node, DepNodeColor::Green(node_index)) .insert(*dep_node, DepNodeColor::Green(node_index))
.is_none()); .is_none());
debug!("try_mark_green({:?}) - END - successfully marked as green", dep_node.kind);
Some(node_index) Some(node_index)
} }