Coverage Report

Created: 2026-09-14 07:40

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
81.4k
    fn default() -> Self {
10
81.4k
        Self {
11
81.4k
            stack: Default::default(),
12
81.4k
        }
13
81.4k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupId> as core::default::Default>::default
Line
Count
Source
9
9.18k
    fn default() -> Self {
10
9.18k
        Self {
11
9.18k
            stack: Default::default(),
12
9.18k
        }
13
9.18k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::RecGroupNode> as core::default::Default>::default
Line
Count
Source
9
1.59k
    fn default() -> Self {
10
1.59k
        Self {
11
1.59k
            stack: Default::default(),
12
1.59k
        }
13
1.59k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime_fuzzing::generators::gc_ops::types::TypeId> as core::default::Default>::default
Line
Count
Source
9
27.5k
    fn default() -> Self {
10
27.5k
        Self {
11
27.5k
            stack: Default::default(),
12
27.5k
        }
13
27.5k
    }
<wasmtime_environ::graphs::dfs::Dfs<wasmtime::compile::OutputIndex> as core::default::Default>::default
Line
Count
Source
9
43.1k
    fn default() -> Self {
10
43.1k
        Self {
11
43.1k
            stack: Default::default(),
12
43.1k
        }
13
43.1k
    }
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
81.4k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
81.4k
        let mut dfs = Self::default();
20
81.4k
        dfs.add_roots(roots);
21
81.4k
        dfs
22
81.4k
    }
<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
9.18k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
9.18k
        let mut dfs = Self::default();
20
9.18k
        dfs.add_roots(roots);
21
9.18k
        dfs
22
9.18k
    }
<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
1.59k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
1.59k
        let mut dfs = Self::default();
20
1.59k
        dfs.add_roots(roots);
21
1.59k
        dfs
22
1.59k
    }
<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
27.5k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
27.5k
        let mut dfs = Self::default();
20
27.5k
        dfs.add_roots(roots);
21
27.5k
        dfs
22
27.5k
    }
<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
43.1k
    pub fn new(roots: impl IntoIterator<Item = Node>) -> Self {
19
43.1k
        let mut dfs = Self::default();
20
43.1k
        dfs.add_roots(roots);
21
43.1k
        dfs
22
43.1k
    }
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
81.4k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
81.4k
        self.stack
32
476k
            .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
8.95k
            .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
4.89k
            .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
65.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
397k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::add_roots::<_>::{closure#0}
33
81.4k
    }
<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
9.18k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
9.18k
        self.stack
32
9.18k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
9.18k
    }
<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
1.59k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
1.59k
        self.stack
32
1.59k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
1.59k
    }
<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
27.5k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
27.5k
        self.stack
32
27.5k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
27.5k
    }
<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
43.1k
    pub fn add_roots(&mut self, roots: impl IntoIterator<Item = Node>) {
31
43.1k
        self.stack
32
43.1k
            .extend(roots.into_iter().map(|v| DfsEvent::Pre(v)));
33
43.1k
    }
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.17M
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
1.17M
    where
58
1.17M
        G: Graph<Node>,
59
    {
60
        loop {
61
1.29M
            let event = self.stack.pop()?;
62
63
1.21M
            if let DfsEvent::Pre(node) = event {
64
590k
                if seen(node) {
65
114k
                    continue;
66
476k
                }
67
68
476k
                let successors = graph.successors(node);
69
70
476k
                let (min, max) = successors.size_hint();
71
476k
                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
476k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
476k
                    2 * estimated_successors_len
75
476k
                        // And we push one post event for this node.
76
476k
                        + 1,
77
                );
78
79
476k
                self.stack.push(DfsEvent::Post(node));
80
476k
                for succ in successors {
81
143k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
143k
                    if !seen(succ) {
83
114k
                        self.stack.push(DfsEvent::Pre(succ));
84
114k
                    }
85
                }
86
619k
            }
87
88
1.09M
            return Some(event);
89
        }
90
1.17M
    }
<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
28.3k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
28.3k
    where
58
28.3k
        G: Graph<Node>,
59
    {
60
        loop {
61
28.9k
            let event = self.stack.pop()?;
62
63
19.7k
            if let DfsEvent::Pre(node) = event {
64
9.52k
                if seen(node) {
65
564
                    continue;
66
8.95k
                }
67
68
8.95k
                let successors = graph.successors(node);
69
70
8.95k
                let (min, max) = successors.size_hint();
71
8.95k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
8.95k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
8.95k
                    2 * estimated_successors_len
75
8.95k
                        // And we push one post event for this node.
76
8.95k
                        + 1,
77
                );
78
79
8.95k
                self.stack.push(DfsEvent::Post(node));
80
8.95k
                for succ in successors {
81
1.24k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
1.24k
                    if !seen(succ) {
83
564
                        self.stack.push(DfsEvent::Pre(succ));
84
676
                    }
85
                }
86
10.1k
            }
87
88
19.1k
            return Some(event);
89
        }
90
28.3k
    }
<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
14.6k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
14.6k
    where
58
14.6k
        G: Graph<Node>,
59
    {
60
        loop {
61
16.1k
            let event = self.stack.pop()?;
62
63
14.5k
            if let DfsEvent::Pre(node) = event {
64
6.45k
                if seen(node) {
65
1.55k
                    continue;
66
4.89k
                }
67
68
4.89k
                let successors = graph.successors(node);
69
70
4.89k
                let (min, max) = successors.size_hint();
71
4.89k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
4.89k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
4.89k
                    2 * estimated_successors_len
75
4.89k
                        // And we push one post event for this node.
76
4.89k
                        + 1,
77
                );
78
79
4.89k
                self.stack.push(DfsEvent::Post(node));
80
4.89k
                for succ in successors {
81
3.21k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
3.21k
                    if !seen(succ) {
83
1.55k
                        self.stack.push(DfsEvent::Pre(succ));
84
1.66k
                    }
85
                }
86
8.11k
            }
87
88
13.0k
            return Some(event);
89
        }
90
14.6k
    }
<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
120k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
120k
    where
58
120k
        G: Graph<Node>,
59
    {
60
        loop {
61
126k
            let event = self.stack.pop()?;
62
63
107k
            if let DfsEvent::Pre(node) = event {
64
49.5k
                if seen(node) {
65
6.09k
                    continue;
66
43.4k
                }
67
68
43.4k
                let successors = graph.successors(node);
69
70
43.4k
                let (min, max) = successors.size_hint();
71
43.4k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
43.4k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
43.4k
                    2 * estimated_successors_len
75
43.4k
                        // And we push one post event for this node.
76
43.4k
                        + 1,
77
                );
78
79
43.4k
                self.stack.push(DfsEvent::Post(node));
80
43.4k
                for succ in successors {
81
14.9k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
14.9k
                    if !seen(succ) {
83
6.09k
                        self.stack.push(DfsEvent::Pre(succ));
84
8.80k
                    }
85
                }
86
58.3k
            }
87
88
101k
            return Some(event);
89
        }
90
120k
    }
<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
60.2k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
60.2k
    where
58
60.2k
        G: Graph<Node>,
59
    {
60
        loop {
61
63.2k
            let event = self.stack.pop()?;
62
63
54.0k
            if let DfsEvent::Pre(node) = event {
64
24.7k
                if seen(node) {
65
3.04k
                    continue;
66
21.7k
                }
67
68
21.7k
                let successors = graph.successors(node);
69
70
21.7k
                let (min, max) = successors.size_hint();
71
21.7k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
21.7k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
21.7k
                    2 * estimated_successors_len
75
21.7k
                        // And we push one post event for this node.
76
21.7k
                        + 1,
77
                );
78
79
21.7k
                self.stack.push(DfsEvent::Post(node));
80
21.7k
                for succ in successors {
81
7.62k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
7.62k
                    if !seen(succ) {
83
3.04k
                        self.stack.push(DfsEvent::Pre(succ));
84
4.57k
                    }
85
                }
86
29.3k
            }
87
88
51.0k
            return Some(event);
89
        }
90
60.2k
    }
<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
954k
    pub fn next<G>(&mut self, graph: G, seen: impl Fn(Node) -> bool) -> Option<DfsEvent<Node>>
57
954k
    where
58
954k
        G: Graph<Node>,
59
    {
60
        loop {
61
1.05M
            let event = self.stack.pop()?;
62
63
1.01M
            if let DfsEvent::Pre(node) = event {
64
500k
                if seen(node) {
65
102k
                    continue;
66
397k
                }
67
68
397k
                let successors = graph.successors(node);
69
70
397k
                let (min, max) = successors.size_hint();
71
397k
                let estimated_successors_len = max.unwrap_or_else(|| 2 * min);
72
397k
                self.stack.reserve(
73
                    // We push an after-edge and pre event for each successor.
74
397k
                    2 * estimated_successors_len
75
397k
                        // And we push one post event for this node.
76
397k
                        + 1,
77
                );
78
79
397k
                self.stack.push(DfsEvent::Post(node));
80
397k
                for succ in successors {
81
116k
                    self.stack.push(DfsEvent::AfterEdge(node, succ));
82
116k
                    if !seen(succ) {
83
102k
                        self.stack.push(DfsEvent::Pre(succ));
84
102k
                    }
85
                }
86
513k
            }
87
88
910k
            return Some(event);
89
        }
90
954k
    }
Unexecuted instantiation: <wasmtime_environ::graphs::dfs::Dfs<_>>::next::<_, _>
91
}