Skip to content

Commit c9a17ef

Browse files
incr.comp.: Add some logging to DepGraph::try_mark_green().
1 parent e1994bd commit c9a17ef

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl fmt::Debug for DepNode {
347347
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
348348
write!(f, "{:?}", self.kind)?;
349349

350-
if !self.kind.has_params() {
350+
if !self.kind.has_params() && !self.kind.is_anon() {
351351
return Ok(());
352352
}
353353

@@ -356,14 +356,14 @@ impl fmt::Debug for DepNode {
356356
::ty::tls::with_opt(|opt_tcx| {
357357
if let Some(tcx) = opt_tcx {
358358
if let Some(def_id) = self.extract_def_id(tcx) {
359-
write!(f, "{}", tcx.item_path_str(def_id))?;
359+
write!(f, "{}", tcx.def_path(def_id).to_string(tcx))?;
360360
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) {
361361
write!(f, "{}", s)?;
362362
} else {
363-
write!(f, "{:?}", self.hash)?;
363+
write!(f, "{}", self.hash)?;
364364
}
365365
} else {
366-
write!(f, "{:?}", self.hash)?;
366+
write!(f, "{}", self.hash)?;
367367
}
368368
Ok(())
369369
})?;

src/librustc/dep_graph/graph.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ impl DepGraph {
429429
tcx: TyCtxt,
430430
dep_node: &DepNode)
431431
-> Option<DepNodeIndex> {
432+
debug!("try_mark_green({:?}) - BEGIN", dep_node);
432433
let data = self.data.as_ref().unwrap();
433434

434435
debug_assert!(!data.colors.borrow().contains_key(dep_node));
@@ -440,6 +441,7 @@ impl DepGraph {
440441
// eagerly marked as either red/green before any queries are
441442
// executed.
442443
debug_assert!(dep_node.extract_def_id(tcx).is_none());
444+
debug!("try_mark_green({:?}) - END - DepNode is deleted input", dep_node);
443445
return None;
444446
}
445447

@@ -454,6 +456,8 @@ impl DepGraph {
454456
None => {
455457
// This DepNode did not exist in the previous compilation session,
456458
// so we cannot mark it as green.
459+
debug!("try_mark_green({:?}) - END - DepNode does not exist in \
460+
current compilation session anymore", dep_node);
457461
return None
458462
}
459463
};
@@ -469,35 +473,56 @@ impl DepGraph {
469473
// This dependency has been marked as green before, we are
470474
// still fine and can continue with checking the other
471475
// dependencies.
476+
debug!("try_mark_green({:?}) --- found dependency {:?} to \
477+
be immediately green", dep_node, dep_dep_node);
472478
current_deps.push(node_index);
473479
}
474480
Some(DepNodeColor::Red) => {
475481
// We found a dependency the value of which has changed
476482
// compared to the previous compilation session. We cannot
477483
// mark the DepNode as green and also don't need to bother
478484
// with checking any of the other dependencies.
485+
debug!("try_mark_green({:?}) - END - dependency {:?} was \
486+
immediately red", dep_node, dep_dep_node);
479487
return None
480488
}
481489
None => {
482490
if dep_dep_node.kind.is_input() {
483491
// This input does not exist anymore.
484492
debug_assert!(dep_dep_node.extract_def_id(tcx).is_none());
493+
debug!("try_mark_green({:?}) - END - dependency {:?} \
494+
was deleted input", dep_node, dep_dep_node);
485495
return None;
486496
}
487497

498+
debug!("try_mark_green({:?}) --- state of dependency {:?} \
499+
is unknown, trying to mark it green", dep_node,
500+
dep_dep_node);
501+
488502
// We don't know the state of this dependency. Let's try to
489503
// mark it green.
490504
if let Some(node_index) = self.try_mark_green(tcx, dep_dep_node) {
505+
debug!("try_mark_green({:?}) --- managed to MARK \
506+
dependency {:?} as green", dep_node, dep_dep_node);
491507
current_deps.push(node_index);
492508
} else {
493509
// We failed to mark it green, so we try to force the query.
510+
debug!("try_mark_green({:?}) --- trying to force \
511+
dependency {:?}", dep_node, dep_dep_node);
494512
if ::ty::maps::force_from_dep_node(tcx, dep_dep_node) {
495513
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node).cloned();
496514
match dep_dep_node_color {
497515
Some(DepNodeColor::Green(node_index)) => {
516+
debug!("try_mark_green({:?}) --- managed to \
517+
FORCE dependency {:?} to green",
518+
dep_node, dep_dep_node);
498519
current_deps.push(node_index);
499520
}
500521
Some(DepNodeColor::Red) => {
522+
debug!("try_mark_green({:?}) - END - \
523+
dependency {:?} was red after forcing",
524+
dep_node,
525+
dep_dep_node);
501526
return None
502527
}
503528
None => {
@@ -507,6 +532,8 @@ impl DepGraph {
507532
}
508533
} else {
509534
// The DepNode could not be forced.
535+
debug!("try_mark_green({:?}) - END - dependency {:?} \
536+
could not be forced", dep_node, dep_dep_node);
510537
return None
511538
}
512539
}
@@ -553,6 +580,7 @@ impl DepGraph {
553580
.insert(*dep_node, DepNodeColor::Green(node_index))
554581
.is_none());
555582

583+
debug!("try_mark_green({:?}) - END - successfully marked as green", dep_node.kind);
556584
Some(node_index)
557585
}
558586

0 commit comments

Comments
 (0)