Skip to content

Commit 620d16a

Browse files
committed
Go back to LEB128 for edges.
1 parent 8b9e38c commit 620d16a

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,7 @@ impl<K: DepKind> DepGraph<K> {
731731
debug_assert_eq!(data.previous.index_to_node(prev_dep_node_index), *dep_node);
732732

733733
let prev_deps = data.previous.edge_targets_from(prev_dep_node_index);
734-
735-
for &dep_dep_node_index in prev_deps {
734+
for dep_dep_node_index in prev_deps {
736735
self.try_mark_parent_green(tcx, data, dep_dep_node_index, dep_node)?
737736
}
738737

compiler/rustc_query_system/src/dep_graph/serialized.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,13 @@ impl<K: DepKind> SerializedDepGraph<K> {
128128
}
129129

130130
#[inline]
131-
pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) -> &[SerializedDepNodeIndex] {
131+
pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) -> Vec<SerializedDepNodeIndex> {
132132
// The encoder has checked that there is no padding there.
133-
if let Some(decoder) = self.decoder_at(source) {
134-
let position = std::mem::size_of::<Fingerprint>();
135-
let &length = unsafe { decoder.mmap_at::<u32>(position) };
136-
unsafe {
137-
decoder.mmap_slice_at::<SerializedDepNodeIndex>(position + 4, length as usize)
138-
}
133+
if let Some(ref mut decoder) = self.decoder_at(source) {
134+
decoder.set_position(std::mem::size_of::<Fingerprint>());
135+
Decodable::decode(decoder)
139136
} else {
140-
&[]
137+
Vec::new()
141138
}
142139
}
143140

@@ -196,10 +193,9 @@ impl<K: DepKind> EncoderState<K> {
196193
fn try_encode_node(&mut self, node: &NodeInfo<K>) -> usize {
197194
let encoder = &mut self.encoder;
198195
let start_pos = encoder.write_mmap(&node.fingerprint);
199-
let _pos = encoder.write_mmap::<u32>(&node.edges.len().try_into().unwrap());
196+
let _pos = encoder.position();
200197
debug_assert_eq!(_pos, start_pos + std::mem::size_of::<Fingerprint>());
201-
let _pos = encoder.write_mmap_slice::<DepNodeIndex>(&node.edges[..]);
202-
debug_assert_eq!(_pos, start_pos + std::mem::size_of::<Fingerprint>() + 4);
198+
node.edges.encode(encoder);
203199
start_pos
204200
}
205201

0 commit comments

Comments
 (0)