Skip to content

Commit

Permalink
Go back to LEB128 for edges.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jul 29, 2022
1 parent 8b9e38c commit 620d16a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_query_system/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,7 @@ impl<K: DepKind> DepGraph<K> {
debug_assert_eq!(data.previous.index_to_node(prev_dep_node_index), *dep_node);

let prev_deps = data.previous.edge_targets_from(prev_dep_node_index);

for &dep_dep_node_index in prev_deps {
for dep_dep_node_index in prev_deps {
self.try_mark_parent_green(tcx, data, dep_dep_node_index, dep_node)?
}

Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_query_system/src/dep_graph/serialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,13 @@ impl<K: DepKind> SerializedDepGraph<K> {
}

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

Expand Down Expand Up @@ -196,10 +193,9 @@ impl<K: DepKind> EncoderState<K> {
fn try_encode_node(&mut self, node: &NodeInfo<K>) -> usize {
let encoder = &mut self.encoder;
let start_pos = encoder.write_mmap(&node.fingerprint);
let _pos = encoder.write_mmap::<u32>(&node.edges.len().try_into().unwrap());
let _pos = encoder.position();
debug_assert_eq!(_pos, start_pos + std::mem::size_of::<Fingerprint>());
let _pos = encoder.write_mmap_slice::<DepNodeIndex>(&node.edges[..]);
debug_assert_eq!(_pos, start_pos + std::mem::size_of::<Fingerprint>() + 4);
node.edges.encode(encoder);
start_pos
}

Expand Down

0 comments on commit 620d16a

Please sign in to comment.