Optimize incremental_verify_ich
This commit is contained in:
@@ -535,13 +535,14 @@ impl<K: DepKind> DepGraph<K> {
|
||||
// value to an existing node.
|
||||
//
|
||||
// For sanity, we still check that the loaded stable hash and the new one match.
|
||||
if let Some(dep_node_index) = data.dep_node_index_of_opt(&node) {
|
||||
let _current_fingerprint =
|
||||
crate::query::incremental_verify_ich(cx, data, result, &node, hash_result);
|
||||
if let Some(prev_index) = data.previous.node_to_index_opt(&node)
|
||||
&& let Some(dep_node_index) = { data.current.prev_index_to_index.lock()[prev_index] }
|
||||
{
|
||||
crate::query::incremental_verify_ich(cx, data, result, prev_index, hash_result);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
if hash_result.is_some() {
|
||||
data.current.record_edge(dep_node_index, node, _current_fingerprint);
|
||||
data.current.record_edge(dep_node_index, node, data.prev_fingerprint_of(prev_index));
|
||||
}
|
||||
|
||||
return dep_node_index;
|
||||
@@ -626,13 +627,19 @@ impl<K: DepKind> DepGraphData<K> {
|
||||
|
||||
/// Returns true if the given node has been marked as green during the
|
||||
/// current compilation session. Used in various assertions
|
||||
pub fn is_green(&self, dep_node: &DepNode<K>) -> bool {
|
||||
self.node_color(dep_node).map_or(false, |c| c.is_green())
|
||||
#[inline]
|
||||
pub fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool {
|
||||
self.colors.get(prev_index).map_or(false, |c| c.is_green())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn prev_fingerprint_of(&self, dep_node: &DepNode<K>) -> Option<Fingerprint> {
|
||||
self.previous.fingerprint_of(dep_node)
|
||||
pub fn prev_fingerprint_of(&self, prev_index: SerializedDepNodeIndex) -> Fingerprint {
|
||||
self.previous.fingerprint_by_index(prev_index)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn prev_node_of(&self, prev_index: SerializedDepNodeIndex) -> DepNode<K> {
|
||||
self.previous.index_to_node(prev_index)
|
||||
}
|
||||
|
||||
pub fn mark_debug_loaded_from_disk(&self, dep_node: DepNode<K>) {
|
||||
@@ -643,7 +650,7 @@ impl<K: DepKind> DepGraphData<K> {
|
||||
impl<K: DepKind> DepGraph<K> {
|
||||
#[inline]
|
||||
pub fn dep_node_exists(&self, dep_node: &DepNode<K>) -> bool {
|
||||
self.data.as_ref().and_then(|data| data.dep_node_index_of_opt(dep_node)).is_some()
|
||||
self.data.as_ref().map_or(false, |data| data.dep_node_exists(dep_node))
|
||||
}
|
||||
|
||||
/// Checks whether a previous work product exists for `v` and, if
|
||||
|
||||
@@ -23,11 +23,15 @@ use std::{fmt, panic};
|
||||
use self::graph::{print_markframe_trace, MarkFrame};
|
||||
|
||||
pub trait DepContext: Copy {
|
||||
type Implicit<'a>: DepContext;
|
||||
type DepKind: self::DepKind;
|
||||
|
||||
/// Create a hashing context for hashing new results.
|
||||
fn with_stable_hashing_context<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
|
||||
|
||||
/// Access the implicit context.
|
||||
fn with_context<R>(f: impl FnOnce(Self::Implicit<'_>) -> R) -> R;
|
||||
|
||||
/// Access the DepGraph.
|
||||
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
|
||||
|
||||
|
||||
@@ -79,11 +79,6 @@ impl<K: DepKind> SerializedDepGraph<K> {
|
||||
self.index.get(dep_node).cloned()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fingerprint_of(&self, dep_node: &DepNode<K>) -> Option<Fingerprint> {
|
||||
self.index.get(dep_node).map(|&node_index| self.fingerprints[node_index])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fingerprint_by_index(&self, dep_node_index: SerializedDepNodeIndex) -> Fingerprint {
|
||||
self.fingerprints[dep_node_index]
|
||||
|
||||
Reference in New Issue
Block a user