Coverage Report

Created: 2026-08-08 08:01

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
83.6k
    fn default() -> Self {
10
83.6k
        Self {
11
83.6k
            stack: Default::default(),
12
83.6k
        }
13
83.6k
    }
<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
3.22k
    fn default() -> Self {
10
3.22k
        Self {
11
3.22k
            stack: Default::default(),
12
3.22k
        }
13
3.22k
    }
<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
36.6k
    fn default() -> Self {
10
36.6k
        Self {
11
36.6k
            stack: Default::default(),
12
36.6k
        }
13
36.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
83.6k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
83.6k
        let mut dfs = Self::default();
20
83.6k
        dfs.add_roots(roots);
21
83.6k
        dfs
22
83.6k
    }
<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
3.22k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
3.22k
        let mut dfs = Self::default();
20
3.22k
        dfs.add_roots(roots);
21
3.22k
        dfs
22
3.22k
    }
<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
36.6k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
36.6k
        let mut dfs = Self::default();
20
36.6k
        dfs.add_roots(roots);
21
36.6k
        dfs
22
36.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
83.6k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
83.6k
        self.stack
32
416k
            .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
13.3k
            .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
8.97k
            .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
78.3k
            .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
315k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::add_roots::<_>::{closure#0}
33
83.6k
    }
<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
3.22k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
3.22k
        self.stack
32
3.22k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
3.22k
    }
<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
36.6k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
36.6k
        self.stack
32
36.6k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
36.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.04M
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
1.04M
    where
58
1.04M
        G: Graph<Node>,
59
    {
60
        loop {
61
1.15M
            let event = self.stack.pop()?;
62
63
1.06M
            if let DfsEvent::Pre(node) = event {
64
525k
                if seen(node) {
65
109k
                    continue;
66
416k
                }
67
68
416k
                let successors = graph.successors(node);
69
70
416k
                let (min, max) = successors.size_hint();
71
416k
                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
416k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
416k
                    2 * estimated_successors_len
75
416k
                        // And we push one post event for this node.
76
416k
                        + 1,
77
                );
78
79
416k
                self.stack.push(DfsEvent::Post(node));
80
416k
                for succ in successors {
81
127k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
127k
                    if !seen(succ) {
83
109k
                        self.stack.push(DfsEvent::Pre(succ));
84
109k
                    }
85
                }
86
544k
            }
87
88
960k
            return Some(event);
89
        }
90
1.04M
    }
<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
39.2k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
39.2k
    where
58
39.2k
        G: Graph<Node>,
59
    {
60
        loop {
61
39.9k
            let event = self.stack.pop()?;
62
63
29.0k
            if let DfsEvent::Pre(node) = event {
64
14.0k
                if seen(node) {
65
714
                    continue;
66
13.3k
                }
67
68
13.3k
                let successors = graph.successors(node);
69
70
13.3k
                let (min, max) = successors.size_hint();
71
13.3k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
13.3k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
13.3k
                    2 * estimated_successors_len
75
13.3k
                        // And we push one post event for this node.
76
13.3k
                        + 1,
77
                );
78
79
13.3k
                self.stack.push(DfsEvent::Post(node));
80
13.3k
                for succ in successors {
81
1.65k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
1.65k
                    if !seen(succ) {
83
714
                        self.stack.push(DfsEvent::Pre(succ));
84
945
                    }
85
                }
86
14.9k
            }
87
88
28.3k
            return Some(event);
89
        }
90
39.2k
    }
<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
23.7k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
23.7k
    where
58
23.7k
        G: Graph<Node>,
59
    {
60
        loop {
61
24.8k
            let event = self.stack.pop()?;
62
63
21.6k
            if let DfsEvent::Pre(node) = event {
64
10.1k
                if seen(node) {
65
1.14k
                    continue;
66
8.97k
                }
67
68
8.97k
                let successors = graph.successors(node);
69
70
8.97k
                let (min, max) = successors.size_hint();
71
8.97k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
8.97k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
8.97k
                    2 * estimated_successors_len
75
8.97k
                        // And we push one post event for this node.
76
8.97k
                        + 1,
77
                );
78
79
8.97k
                self.stack.push(DfsEvent::Post(node));
80
8.97k
                for succ in successors {
81
2.55k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
2.55k
                    if !seen(succ) {
83
1.14k
                        self.stack.push(DfsEvent::Pre(succ));
84
1.41k
                    }
85
                }
86
11.5k
            }
87
88
20.5k
            return Some(event);
89
        }
90
23.7k
    }
<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
134k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
134k
    where
58
134k
        G: Graph<Node>,
59
    {
60
        loop {
61
138k
            let event = self.stack.pop()?;
62
63
116k
            if let DfsEvent::Pre(node) = event {
64
56.1k
                if seen(node) {
65
3.89k
                    continue;
66
52.2k
                }
67
68
52.2k
                let successors = graph.successors(node);
69
70
52.2k
                let (min, max) = successors.size_hint();
71
52.2k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
52.2k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
52.2k
                    2 * estimated_successors_len
75
52.2k
                        // And we push one post event for this node.
76
52.2k
                        + 1,
77
                );
78
79
52.2k
                self.stack.push(DfsEvent::Post(node));
80
52.2k
                for succ in successors {
81
8.36k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
8.36k
                    if !seen(succ) {
83
3.89k
                        self.stack.push(DfsEvent::Pre(succ));
84
4.46k
                    }
85
                }
86
60.5k
            }
87
88
112k
            return Some(event);
89
        }
90
134k
    }
<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
67.5k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
67.5k
    where
58
67.5k
        G: Graph<Node>,
59
    {
60
        loop {
61
69.6k
            let event = self.stack.pop()?;
62
63
58.6k
            if let DfsEvent::Pre(node) = event {
64
28.2k
                if seen(node) {
65
2.11k
                    continue;
66
26.1k
                }
67
68
26.1k
                let successors = graph.successors(node);
69
70
26.1k
                let (min, max) = successors.size_hint();
71
26.1k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
26.1k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
26.1k
                    2 * estimated_successors_len
75
26.1k
                        // And we push one post event for this node.
76
26.1k
                        + 1,
77
                );
78
79
26.1k
                self.stack.push(DfsEvent::Post(node));
80
26.1k
                for succ in successors {
81
4.35k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
4.35k
                    if !seen(succ) {
83
2.11k
                        self.stack.push(DfsEvent::Pre(succ));
84
2.24k
                    }
85
                }
86
30.4k
            }
87
88
56.5k
            return Some(event);
89
        }
90
67.5k
    }
<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
778k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
778k
    where
58
778k
        G: Graph<Node>,
59
    {
60
        loop {
61
879k
            let event = self.stack.pop()?;
62
63
843k
            if let DfsEvent::Pre(node) = event {
64
416k
                if seen(node) {
65
101k
                    continue;
66
315k
                }
67
68
315k
                let successors = graph.successors(node);
69
70
315k
                let (min, max) = successors.size_hint();
71
315k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
315k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
315k
                    2 * estimated_successors_len
75
315k
                        // And we push one post event for this node.
76
315k
                        + 1,
77
                );
78
79
315k
                self.stack.push(DfsEvent::Post(node));
80
315k
                for succ in successors {
81
110k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
110k
                    if !seen(succ) {
83
101k
                        self.stack.push(DfsEvent::Pre(succ));
84
101k
                    }
85
                }
86
426k
            }
87
88
741k
            return Some(event);
89
        }
90
778k
    }
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::next::<_, _>
91
}