|
10 | 10 |
|
11 | 11 | //! The data that we will serialize and deserialize.
|
12 | 12 |
|
13 |
| -use rustc::dep_graph::{DepNode, WorkProduct, WorkProductId}; |
| 13 | +use rustc::dep_graph::{WorkProduct, WorkProductId}; |
14 | 14 | use rustc::hir::def_id::DefIndex;
|
15 | 15 | use rustc::hir::map::DefPathHash;
|
16 |
| -use rustc::ich::Fingerprint; |
17 | 16 | use rustc::middle::cstore::EncodedMetadataHash;
|
18 | 17 | use rustc_data_structures::fx::FxHashMap;
|
19 |
| -use rustc_data_structures::indexed_vec::{IndexVec, Idx}; |
20 |
| - |
21 |
| -/// Data for use when recompiling the **current crate**. |
22 |
| -#[derive(Debug, RustcEncodable, RustcDecodable)] |
23 |
| -pub struct SerializedDepGraph { |
24 |
| - /// The set of all DepNodes in the graph |
25 |
| - pub nodes: IndexVec<DepNodeIndex, DepNode>, |
26 |
| - /// For each DepNode, stores the list of edges originating from that |
27 |
| - /// DepNode. Encoded as a [start, end) pair indexing into edge_list_data, |
28 |
| - /// which holds the actual DepNodeIndices of the target nodes. |
29 |
| - pub edge_list_indices: IndexVec<DepNodeIndex, (u32, u32)>, |
30 |
| - /// A flattened list of all edge targets in the graph. Edge sources are |
31 |
| - /// implicit in edge_list_indices. |
32 |
| - pub edge_list_data: Vec<DepNodeIndex>, |
33 |
| - |
34 |
| - /// These are output nodes that have no incoming edges. We track |
35 |
| - /// these separately so that when we reload all edges, we don't |
36 |
| - /// lose track of these nodes. |
37 |
| - pub bootstrap_outputs: Vec<DepNode>, |
38 |
| - |
39 |
| - /// These are hashes of two things: |
40 |
| - /// - the HIR nodes in this crate |
41 |
| - /// - the metadata nodes from dependent crates we use |
42 |
| - /// |
43 |
| - /// In each case, we store a hash summarizing the contents of |
44 |
| - /// those items as they were at the time we did this compilation. |
45 |
| - /// In the case of HIR nodes, this hash is derived by walking the |
46 |
| - /// HIR itself. In the case of metadata nodes, the hash is loaded |
47 |
| - /// from saved state. |
48 |
| - /// |
49 |
| - /// When we do the next compile, we will load these back up and |
50 |
| - /// compare them against the hashes we see at that time, which |
51 |
| - /// will tell us what has changed, either in this crate or in some |
52 |
| - /// crate that we depend on. |
53 |
| - /// |
54 |
| - /// Because they will be reloaded, we don't store the DefId (which |
55 |
| - /// will be different when we next compile) related to each node, |
56 |
| - /// but rather the `DefPathIndex`. This can then be retraced |
57 |
| - /// to find the current def-id. |
58 |
| - pub hashes: Vec<(DepNodeIndex, Fingerprint)>, |
59 |
| -} |
60 |
| - |
61 |
| -impl SerializedDepGraph { |
62 |
| - pub fn edge_targets_from(&self, source: DepNodeIndex) -> &[DepNodeIndex] { |
63 |
| - let targets = self.edge_list_indices[source]; |
64 |
| - &self.edge_list_data[targets.0 as usize .. targets.1 as usize] |
65 |
| - } |
66 |
| -} |
67 |
| - |
68 |
| -/// The index of a DepNode in the SerializedDepGraph::nodes array. |
69 |
| -#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug, |
70 |
| - RustcEncodable, RustcDecodable)] |
71 |
| -pub struct DepNodeIndex(pub u32); |
72 |
| - |
73 |
| -impl Idx for DepNodeIndex { |
74 |
| - #[inline] |
75 |
| - fn new(idx: usize) -> Self { |
76 |
| - assert!(idx <= ::std::u32::MAX as usize); |
77 |
| - DepNodeIndex(idx as u32) |
78 |
| - } |
79 |
| - |
80 |
| - #[inline] |
81 |
| - fn index(self) -> usize { |
82 |
| - self.0 as usize |
83 |
| - } |
84 |
| -} |
85 | 18 |
|
86 | 19 | #[derive(Debug, RustcEncodable, RustcDecodable)]
|
87 | 20 | pub struct SerializedWorkProduct {
|
|
0 commit comments