Skip to content

Inline mark_neighbours_as_waiting_from. #64420

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

Merged
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
17 changes: 13 additions & 4 deletions src/librustc_data_structures/obligation_forest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,20 @@ impl<O: ForestObligation> ObligationForest<O> {
trace
}

#[inline]
fn mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
// This always-inlined function is for the hot call site.
#[inline(always)]
fn inlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
for dependent in node.parent.iter().chain(node.dependents.iter()) {
self.mark_as_waiting_from(&self.nodes[dependent.get()]);
}
}

// This never-inlined function is for the cold call site.
#[inline(never)]
fn uninlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
self.inlined_mark_neighbors_as_waiting_from(node)
}

/// Marks all nodes that depend on a pending node as `NodeState::Waiting`.
fn mark_as_waiting(&self) {
for node in &self.nodes {
Expand All @@ -576,7 +583,8 @@ impl<O: ForestObligation> ObligationForest<O> {

for node in &self.nodes {
if node.state.get() == NodeState::Pending {
self.mark_neighbors_as_waiting_from(node);
// This call site is hot.
self.inlined_mark_neighbors_as_waiting_from(node);
}
}
}
Expand All @@ -588,7 +596,8 @@ impl<O: ForestObligation> ObligationForest<O> {
NodeState::Pending | NodeState::Done => {},
}

self.mark_neighbors_as_waiting_from(node);
// This call site is cold.
self.uninlined_mark_neighbors_as_waiting_from(node);
}

/// Compresses the vector, removing all popped nodes. This adjusts
Expand Down