Coverage Report

Created: 2026-10-31 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wasmtime/crates/environ/src/graphs/dfs.rs
Line
Count
Source
1
use super::*;
2
3
/// An iterative depth-first traversal.
4
pub struct Dfs<Node> {
5
    stack: Vec<DfsEvent<Node>>,
6
}
7
8
impl<Node> Default for Dfs<Node> {
9
102k
    fn default() -> Self {
10
102k
        Self {
11
102k
            stack: Default::default(),
12
102k
        }
13
102k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId> as core::default::Default>::default
Line
Count
Source
9
10.9k
    fn default() -> Self {
10
10.9k
        Self {
11
10.9k
            stack: Default::default(),
12
10.9k
        }
13
10.9k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode> as core::default::Default>::default
Line
Count
Source
9
2.01k
    fn default() -> Self {
10
2.01k
        Self {
11
2.01k
            stack: Default::default(),
12
2.01k
        }
13
2.01k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId> as core::default::Default>::default
Line
Count
Source
9
32.7k
    fn default() -> Self {
10
32.7k
        Self {
11
32.7k
            stack: Default::default(),
12
32.7k
        }
13
32.7k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex> as core::default::Default>::default
Line
Count
Source
9
56.6k
    fn default() -> Self {
10
56.6k
        Self {
11
56.6k
            stack: Default::default(),
12
56.6k
        }
13
56.6k
    }
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_> as core::default::Default>::default
14
}
15
16
impl<Node> Dfs<Node> {
17
    /// Create a new DFS traversal, starting at the given roots.
18
102k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
102k
        let mut dfs = Self::default();
20
102k
        dfs.add_roots(roots);
21
102k
        dfs
22
102k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId>>::new::<core::iter::adapters::copied::Copied<alloc::collections::btree::map::Keys<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId, alloc::collections::btree::set::BTreeSet<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>>>
Line
Count
Source
18
10.9k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
10.9k
        let mut dfs = Self::default();
20
10.9k
        dfs.add_roots(roots);
21
10.9k
        dfs
22
10.9k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::new::<core::iter::adapters::map::Map<core::ops::range::Range<u32>, fn(u32) -> wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>
Line
Count
Source
18
2.01k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
2.01k
        let mut dfs = Self::default();
20
2.01k
        dfs.add_roots(roots);
21
2.01k
        dfs
22
2.01k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::new::<core::iter::adapters::copied::Copied<alloc::collections::btree::map::Keys<wasmtime_fuzzing::generators::gc_ops::types::TypeId, wasmtime_fuzzing::generators::gc_ops::types::SubType>>>
Line
Count
Source
18
32.7k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
32.7k
        let mut dfs = Self::default();
20
32.7k
        dfs.add_roots(roots);
21
32.7k
        dfs
22
32.7k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex>>::new::<core::iter::adapters::filter::Filter<cranelift_entity::keys::Keys<wasmtime::compile::OutputIndex>, &<wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>>
Line
Count
Source
18
56.6k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
56.6k
        let mut dfs = Self::default();
20
56.6k
        dfs.add_roots(roots);
21
56.6k
        dfs
22
56.6k
    }
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::new::<_>
23
24
    /// Add a single new root to this traversal, to be visited immediately.
25
0
    pub fn add_root(&mut self, root: Node) {
26
0
        self.stack.push(DfsEvent::Pre(root));
27
0
    }
28
29
    /// Add multiple new roots to this traversal, to be visited immediately.
30
102k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
102k
        self.stack
32
625k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId>>::add_roots::<core::iter::adapters::copied::Copied<alloc::collections::btree::map::Keys<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId, alloc::collections::btree::set::BTreeSet<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>>>::{closure#0}
Line
Count
Source
32
10.7k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::add_roots::<core::iter::adapters::map::Map<core::ops::range::Range<u32>, fn(u32) -> wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::{closure#0}
Line
Count
Source
32
6.04k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::add_roots::<core::iter::adapters::copied::Copied<alloc::collections::btree::map::Keys<wasmtime_fuzzing::generators::gc_ops::types::TypeId, wasmtime_fuzzing::generators::gc_ops::types::SubType>>>::{closure#0}
Line
Count
Source
32
82.1k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
<wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex>>::add_roots::<core::iter::adapters::filter::Filter<cranelift_entity::keys::Keys<wasmtime::compile::OutputIndex>, &<wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>>::{closure#0}
Line
Count
Source
32
526k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::add_roots::<_>::{closure#0}
33
102k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId>>::add_roots::<core::iter::adapters::copied::Copied<alloc::collections::btree::map::Keys<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId, alloc::collections::btree::set::BTreeSet<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>>>
Line
Count
Source
30
10.9k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
10.9k
        self.stack
32
10.9k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
10.9k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::add_roots::<core::iter::adapters::map::Map<core::ops::range::Range<u32>, fn(u32) -> wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>
Line
Count
Source
30
2.01k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
2.01k
        self.stack
32
2.01k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
2.01k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::add_roots::<core::iter::adapters::copied::Copied<alloc::collections::btree::map::Keys<wasmtime_fuzzing::generators::gc_ops::types::TypeId, wasmtime_fuzzing::generators::gc_ops::types::SubType>>>
Line
Count
Source
30
32.7k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
32.7k
        self.stack
32
32.7k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
32.7k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex>>::add_roots::<core::iter::adapters::filter::Filter<cranelift_entity::keys::Keys<wasmtime::compile::OutputIndex>, &<wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>>
Line
Count
Source
30
56.6k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
56.6k
        self.stack
32
56.6k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
56.6k
    }
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::add_roots::<_>
34
}
35
36
/// An event during a DFS traversal.
37
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
38
pub enum DfsEvent<Node> {
39
    /// The first time seeing this node.
40
    Pre(Node),
41
42
    /// After having just visited the given edge.
43
    AfterEdge(Node, Node),
44
45
    /// Finished visiting this node and all of its successors.
46
    Post(Node),
47
}
48
49
impl<Node> Dfs<Node>
50
where
51
    Node: Copy,
52
{
53
    /// Pump the traversal, yielding the next `DfsEvent`.
54
    ///
55
    /// Returns `None` when the traversal is complete.
56
1.54M
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
1.54M
    where
58
1.54M
        G: Graph<Node>,
59
    {
60
        loop {
61
1.70M
            let event = self.stack.pop()?;
62
63
1.60M
            if let DfsEvent::Pre(node) = event {
64
782k
                if seen(node) {
65
157k
                    continue;
66
625k
                }
67
68
625k
                let successors = graph.successors(node);
69
70
625k
                let (min, max) = successors.size_hint();
71
625k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId>>::next::<&wasmtime_fuzzing::generators::gc_ops::types::RecGroupGraph, <wasmtime_fuzzing::generators::gc_ops::types::Types>::sort_rec_groups_topo::{closure#0}>::{closure#0}
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::next::<&&wasmtime_fuzzing::generators::gc_ops::types::DenseRecGroupGraph, <wasmtime_environ::graphs::scc::StronglyConnectedComponents<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::new<&wasmtime_fuzzing::generators::gc_ops::types::DenseRecGroupGraph>::{closure#1}>::{closure#0}
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::next::<&wasmtime_fuzzing::generators::gc_ops::types::SupertypeGraph, <wasmtime_fuzzing::generators::gc_ops::types::Types>::sort_types_topo::{closure#0}>::{closure#0}
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::next::<&wasmtime_fuzzing::generators::gc_ops::types::SupertypeGraph, <wasmtime_fuzzing::generators::gc_ops::types::Types>::break_supertype_cycles::{closure#0}>::{closure#0}
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex>>::next::<&&wasmtime_environ::graphs::FilterNodes<wasmtime_environ::graphs::entity_graph::EntityGraph<wasmtime::compile::OutputIndex>, <wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>, <wasmtime_environ::graphs::scc::StronglyConnectedComponents<wasmtime::compile::OutputIndex>>::new<&wasmtime_environ::graphs::FilterNodes<wasmtime_environ::graphs::entity_graph::EntityGraph<wasmtime::compile::OutputIndex>, <wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>>::{closure#1}>::{closure#0}
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::next::<_, _>::{closure#0}
72
625k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
625k
                    2 * estimated_successors_len
75
625k
                        // And we push one post event for this node.
76
625k
                        + 1,
77
                );
78
79
625k
                self.stack.push(DfsEvent::Post(node));
80
625k
                for succ in successors {
81
195k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
195k
                    if !seen(succ) {
83
157k
                        self.stack.push(DfsEvent::Pre(succ));
84
157k
                    }
85
                }
86
820k
            }
87
88
1.44M
            return Some(event);
89
        }
90
1.54M
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId>>::next::<&wasmtime_fuzzing::generators::gc_ops::types::RecGroupGraph, <wasmtime_fuzzing::generators::gc_ops::types::Types>::sort_rec_groups_topo::{closure#0}>
Line
Count
Source
56
34.0k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
34.0k
    where
58
34.0k
        G: Graph<Node>,
59
    {
60
        loop {
61
34.7k
            let event = self.stack.pop()?;
62
63
23.8k
            if let DfsEvent::Pre(node) = event {
64
11.5k
                if seen(node) {
65
722
                    continue;
66
10.7k
                }
67
68
10.7k
                let successors = graph.successors(node);
69
70
10.7k
                let (min, max) = successors.size_hint();
71
10.7k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
10.7k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
10.7k
                    2 * estimated_successors_len
75
10.7k
                        // And we push one post event for this node.
76
10.7k
                        + 1,
77
                );
78
79
10.7k
                self.stack.push(DfsEvent::Post(node));
80
10.7k
                for succ in successors {
81
1.52k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
1.52k
                    if !seen(succ) {
83
722
                        self.stack.push(DfsEvent::Pre(succ));
84
801
                    }
85
                }
86
12.3k
            }
87
88
23.0k
            return Some(event);
89
        }
90
34.0k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::next::<&&wasmtime_fuzzing::generators::gc_ops::types::DenseRecGroupGraph, <wasmtime_environ::graphs::scc::StronglyConnectedComponents<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode>>::new<&wasmtime_fuzzing::generators::gc_ops::types::DenseRecGroupGraph>::{closure#1}>
Line
Count
Source
56
17.8k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
17.8k
    where
58
17.8k
        G: Graph<Node>,
59
    {
60
        loop {
61
19.7k
            let event = self.stack.pop()?;
62
63
17.7k
            if let DfsEvent::Pre(node) = event {
64
7.91k
                if seen(node) {
65
1.86k
                    continue;
66
6.04k
                }
67
68
6.04k
                let successors = graph.successors(node);
69
70
6.04k
                let (min, max) = successors.size_hint();
71
6.04k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
6.04k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
6.04k
                    2 * estimated_successors_len
75
6.04k
                        // And we push one post event for this node.
76
6.04k
                        + 1,
77
                );
78
79
6.04k
                self.stack.push(DfsEvent::Post(node));
80
6.04k
                for succ in successors {
81
3.79k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
3.79k
                    if !seen(succ) {
83
1.86k
                        self.stack.push(DfsEvent::Pre(succ));
84
1.92k
                    }
85
                }
86
9.83k
            }
87
88
15.8k
            return Some(event);
89
        }
90
17.8k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::next::<&wasmtime_fuzzing::generators::gc_ops::types::SupertypeGraph, <wasmtime_fuzzing::generators::gc_ops::types::Types>::sort_types_topo::{closure#0}>
Line
Count
Source
56
150k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
150k
    where
58
150k
        G: Graph<Node>,
59
    {
60
        loop {
61
157k
            let event = self.stack.pop()?;
62
63
135k
            if let DfsEvent::Pre(node) = event {
64
62.1k
                if seen(node) {
65
7.37k
                    continue;
66
54.7k
                }
67
68
54.7k
                let successors = graph.successors(node);
69
70
54.7k
                let (min, max) = successors.size_hint();
71
54.7k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
54.7k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
54.7k
                    2 * estimated_successors_len
75
54.7k
                        // And we push one post event for this node.
76
54.7k
                        + 1,
77
                );
78
79
54.7k
                self.stack.push(DfsEvent::Post(node));
80
54.7k
                for succ in successors {
81
18.9k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
18.9k
                    if !seen(succ) {
83
7.37k
                        self.stack.push(DfsEvent::Pre(succ));
84
11.5k
                    }
85
                }
86
73.6k
            }
87
88
128k
            return Some(event);
89
        }
90
150k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId>>::next::<&wasmtime_fuzzing::generators::gc_ops::types::SupertypeGraph, <wasmtime_fuzzing::generators::gc_ops::types::Types>::break_supertype_cycles::{closure#0}>
Line
Count
Source
56
75.3k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
75.3k
    where
58
75.3k
        G: Graph<Node>,
59
    {
60
        loop {
61
79.0k
            let event = self.stack.pop()?;
62
63
68.1k
            if let DfsEvent::Pre(node) = event {
64
31.0k
                if seen(node) {
65
3.68k
                    continue;
66
27.3k
                }
67
68
27.3k
                let successors = graph.successors(node);
69
70
27.3k
                let (min, max) = successors.size_hint();
71
27.3k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
27.3k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
27.3k
                    2 * estimated_successors_len
75
27.3k
                        // And we push one post event for this node.
76
27.3k
                        + 1,
77
                );
78
79
27.3k
                self.stack.push(DfsEvent::Post(node));
80
27.3k
                for succ in successors {
81
9.68k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
9.68k
                    if !seen(succ) {
83
3.68k
                        self.stack.push(DfsEvent::Pre(succ));
84
5.99k
                    }
85
                }
86
37.0k
            }
87
88
64.4k
            return Some(event);
89
        }
90
75.3k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex>>::next::<&&wasmtime_environ::graphs::FilterNodes<wasmtime_environ::graphs::entity_graph::EntityGraph<wasmtime::compile::OutputIndex>, <wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>, <wasmtime_environ::graphs::scc::StronglyConnectedComponents<wasmtime::compile::OutputIndex>>::new<&wasmtime_environ::graphs::FilterNodes<wasmtime_environ::graphs::entity_graph::EntityGraph<wasmtime::compile::OutputIndex>, <wasmtime::compile::CompileInputs>::compile_with_inlining::{closure#3}>>::{closure#1}>
Line
Count
Source
56
1.27M
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
1.27M
    where
58
1.27M
        G: Graph<Node>,
59
    {
60
        loop {
61
1.41M
            let event = self.stack.pop()?;
62
63
1.35M
            if let DfsEvent::Pre(node) = event {
64
670k
                if seen(node) {
65
143k
                    continue;
66
526k
                }
67
68
526k
                let successors = graph.successors(node);
69
70
526k
                let (min, max) = successors.size_hint();
71
526k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
526k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
526k
                    2 * estimated_successors_len
75
526k
                        // And we push one post event for this node.
76
526k
                        + 1,
77
                );
78
79
526k
                self.stack.push(DfsEvent::Post(node));
80
526k
                for succ in successors {
81
161k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
161k
                    if !seen(succ) {
83
143k
                        self.stack.push(DfsEvent::Pre(succ));
84
143k
                    }
85
                }
86
688k
            }
87
88
1.21M
            return Some(event);
89
        }
90
1.27M
    }
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::next::<_, _>
91
}