2017-09-22 13:00:42 +02:00
|
|
|
//! The data that we will serialize and deserialize.
|
|
|
|
|
2019-02-05 11:20:45 -06:00
|
|
|
use crate::dep_graph::DepNode;
|
|
|
|
use crate::ich::Fingerprint;
|
2019-12-22 17:42:04 -05:00
|
|
|
use rustc_index::vec::{Idx, IndexVec};
|
2017-09-22 13:00:42 +02:00
|
|
|
|
2019-09-26 05:38:33 +00:00
|
|
|
rustc_index::newtype_index! {
|
2018-07-25 13:41:32 +03:00
|
|
|
pub struct SerializedDepNodeIndex { .. }
|
|
|
|
}
|
2017-09-22 13:00:42 +02:00
|
|
|
|
|
|
|
/// Data for use when recompiling the **current crate**.
|
2018-10-16 16:57:53 +02:00
|
|
|
#[derive(Debug, RustcEncodable, RustcDecodable, Default)]
|
2017-09-22 13:00:42 +02:00
|
|
|
pub struct SerializedDepGraph {
|
|
|
|
/// The set of all DepNodes in the graph
|
2018-03-15 18:56:20 -04:00
|
|
|
pub nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
|
|
|
|
/// The set of all Fingerprints in the graph. Each Fingerprint corresponds to
|
|
|
|
/// the DepNode at the same index in the nodes vector.
|
|
|
|
pub fingerprints: IndexVec<SerializedDepNodeIndex, Fingerprint>,
|
2017-09-22 13:00:42 +02:00
|
|
|
/// For each DepNode, stores the list of edges originating from that
|
|
|
|
/// DepNode. Encoded as a [start, end) pair indexing into edge_list_data,
|
|
|
|
/// which holds the actual DepNodeIndices of the target nodes.
|
|
|
|
pub edge_list_indices: IndexVec<SerializedDepNodeIndex, (u32, u32)>,
|
|
|
|
/// A flattened list of all edge targets in the graph. Edge sources are
|
|
|
|
/// implicit in edge_list_indices.
|
|
|
|
pub edge_list_data: Vec<SerializedDepNodeIndex>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SerializedDepGraph {
|
2017-09-28 16:19:10 +02:00
|
|
|
#[inline]
|
2019-12-22 17:42:04 -05:00
|
|
|
pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) -> &[SerializedDepNodeIndex] {
|
2017-09-22 13:00:42 +02:00
|
|
|
let targets = self.edge_list_indices[source];
|
|
|
|
&self.edge_list_data[targets.0 as usize..targets.1 as usize]
|
|
|
|
}
|
|
|
|
}
|