Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SmallVec for DepNodeIndex within dep_graph. #50565

Merged
merged 1 commit into from
May 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use errors::DiagnosticBuilder;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_data_structures::small_vec::SmallVec;
use rustc_data_structures::sync::{Lrc, RwLock, ReadGuard, Lock};
use std::env;
use std::hash::Hash;
Expand Down Expand Up @@ -131,7 +132,7 @@ impl DepGraph {
let mut edges = Vec::new();
for (index, edge_targets) in current_dep_graph.edges.iter_enumerated() {
let from = current_dep_graph.nodes[index];
for &edge_target in edge_targets {
for &edge_target in edge_targets.iter() {
let to = current_dep_graph.nodes[edge_target];
edges.push((from, to));
}
Expand Down Expand Up @@ -209,7 +210,7 @@ impl DepGraph {
self.with_task_impl(key, cx, arg, false, task,
|key| OpenTask::Regular(Lock::new(RegularOpenTask {
node: key,
reads: Vec::new(),
reads: SmallVec::new(),
read_set: FxHashSet(),
})),
|data, key, task| data.borrow_mut().complete_task(key, task))
Expand All @@ -230,7 +231,7 @@ impl DepGraph {

self.with_task_impl(key, cx, input, true, identity_fn,
|_| OpenTask::Ignore,
|data, key, _| data.borrow_mut().alloc_node(key, Vec::new()))
|data, key, _| data.borrow_mut().alloc_node(key, SmallVec::new()))
}

fn with_task_impl<'gcx, C, A, R>(
Expand Down Expand Up @@ -353,7 +354,7 @@ impl DepGraph {
if let Some(ref data) = self.data {
let (result, open_task) = ty::tls::with_context(|icx| {
let task = OpenTask::Anon(Lock::new(AnonOpenTask {
reads: Vec::new(),
reads: SmallVec::new(),
read_set: FxHashSet(),
}));

Expand Down Expand Up @@ -626,7 +627,7 @@ impl DepGraph {

debug_assert!(data.colors.borrow().get(prev_dep_node_index).is_none());

let mut current_deps = Vec::new();
let mut current_deps = SmallVec::new();

for &dep_dep_node_index in prev_deps {
let dep_dep_node_color = data.colors.borrow().get(dep_dep_node_index);
Expand Down Expand Up @@ -923,7 +924,7 @@ pub enum WorkProductFileKind {

pub(super) struct CurrentDepGraph {
nodes: IndexVec<DepNodeIndex, DepNode>,
edges: IndexVec<DepNodeIndex, Vec<DepNodeIndex>>,
edges: IndexVec<DepNodeIndex, SmallVec<[DepNodeIndex; 8]>>,
node_to_node_index: FxHashMap<DepNode, DepNodeIndex>,
forbidden_edge: Option<EdgeFilter>,

Expand Down Expand Up @@ -1061,7 +1062,7 @@ impl CurrentDepGraph {
} = task {
debug_assert_eq!(node, key);
let krate_idx = self.node_to_node_index[&DepNode::new_no_params(DepKind::Krate)];
self.alloc_node(node, vec![krate_idx])
self.alloc_node(node, SmallVec::one(krate_idx))
} else {
bug!("complete_eval_always_task() - Expected eval always task to be popped");
}
Expand Down Expand Up @@ -1107,7 +1108,7 @@ impl CurrentDepGraph {

fn alloc_node(&mut self,
dep_node: DepNode,
edges: Vec<DepNodeIndex>)
edges: SmallVec<[DepNodeIndex; 8]>)
-> DepNodeIndex {
debug_assert_eq!(self.edges.len(), self.nodes.len());
debug_assert_eq!(self.node_to_node_index.len(), self.nodes.len());
Expand All @@ -1122,12 +1123,12 @@ impl CurrentDepGraph {

pub struct RegularOpenTask {
node: DepNode,
reads: Vec<DepNodeIndex>,
reads: SmallVec<[DepNodeIndex; 8]>,
read_set: FxHashSet<DepNodeIndex>,
}

pub struct AnonOpenTask {
reads: Vec<DepNodeIndex>,
reads: SmallVec<[DepNodeIndex; 8]>,
read_set: FxHashSet<DepNodeIndex>,
}

Expand Down