Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 3da19a9

Browse files
authored
Implement Tarjan's strongly-connected components algorithm (#11239)
* Implement Tarjan's strongly-connected components algorithm This commit implements [Tarjan's algorithm] for finding strongly-connected components. This algorithm takes `O(V+E)` time and uses `O(V+E)` space. Tarjan's algorithm is usually presented as a recursive algorithm, but we do not trust the input and cannot recurse over it for fear of blowing the stack. Therefore, this implementation is iterative. This will be used to do bottom-up inlining in Wasmtime's compilation orchestration. [Tarjan's algorithm]: https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm * address review feedback
1 parent 27b1860 commit 3da19a9

3 files changed

Lines changed: 552 additions & 0 deletions

File tree

cranelift/entity/src/set.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ where
148148
self.bitset.insert(index)
149149
}
150150

151+
/// Remove `k` from this bitset.
152+
///
153+
/// Returns whether `k` was previously in this set or not.
154+
pub fn remove(&mut self, k: K) -> bool {
155+
let index = k.index();
156+
self.bitset.remove(index)
157+
}
158+
151159
/// Removes and returns the entity from the set if it exists.
152160
pub fn pop(&mut self) -> Option<K> {
153161
let index = self.bitset.pop()?;

crates/wasmtime/src/compile.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ use wasmtime_environ::{
4343
StaticModuleIndex,
4444
};
4545

46+
mod scc;
47+
4648
mod code_builder;
4749
pub use self::code_builder::{CodeBuilder, CodeHint, HashedEngineCompileEnv};
4850

0 commit comments

Comments
 (0)