Coverage Report

Created: 2026-08-28 08:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wasmtime/crates/environ/src/gc/drc.rs
Line
Count
Source
1
//! Layout of Wasm GC objects in the deferred reference-counting collector.
2
3
use super::*;
4
5
/// The size of the `VMDrcHeader` header for GC objects.
6
pub const HEADER_SIZE: u32 = 24;
7
8
/// The align of the `VMDrcHeader` header for GC objects.
9
pub const HEADER_ALIGN: u32 = 8;
10
11
/// The offset of the length field in a `VMDrcArrayHeader`.
12
pub const ARRAY_LENGTH_OFFSET: u32 = HEADER_SIZE;
13
14
/// The offset of the tag-instance-index field in an exception header.
15
pub const EXCEPTION_TAG_INSTANCE_OFFSET: u32 = HEADER_SIZE;
16
17
/// The offset of the tag-defined-index field in an exception header.
18
pub const EXCEPTION_TAG_DEFINED_OFFSET: u32 = HEADER_SIZE + 4;
19
20
pub use super::DRC_HEADER_IN_OVER_APPROX_LIST_BIT as HEADER_IN_OVER_APPROX_LIST_BIT;
21
pub use super::DRC_HEADER_MARK_BIT as HEADER_MARK_BIT;
22
pub use super::DRC_MIN_OVER_APPROX_STACK_ROOTS_GC_THRESHOLD as MIN_OVER_APPROX_STACK_ROOTS_GC_THRESHOLD;
23
24
/// The layout of Wasm GC objects in the deferred reference-counting collector.
25
#[derive(Default)]
26
pub struct DrcTypeLayouts;
27
28
impl GcTypeLayouts for DrcTypeLayouts {
29
28.7k
    fn array_length_field_offset(&self) -> u32 {
30
28.7k
        ARRAY_LENGTH_OFFSET
31
28.7k
    }
32
33
7.69k
    fn exception_tag_instance_offset(&self) -> u32 {
34
7.69k
        EXCEPTION_TAG_INSTANCE_OFFSET
35
7.69k
    }
36
37
7.69k
    fn exception_tag_defined_offset(&self) -> u32 {
38
7.69k
        EXCEPTION_TAG_DEFINED_OFFSET
39
7.69k
    }
40
41
385k
    fn array_layout(&self, ty: &WasmArrayType) -> GcArrayLayout {
42
385k
        common_array_layout(ty, HEADER_SIZE, HEADER_ALIGN, ARRAY_LENGTH_OFFSET)
43
385k
    }
44
45
201k
    fn struct_layout(&self, ty: &WasmStructType) -> Result<GcStructLayout, OutOfMemory> {
46
201k
        common_struct_layout(ty, HEADER_SIZE, HEADER_ALIGN)
47
201k
    }
48
49
24.5k
    fn exn_layout(&self, ty: &WasmExnType) -> Result<GcStructLayout, OutOfMemory> {
50
24.5k
        common_exn_layout(ty, HEADER_SIZE, HEADER_ALIGN)
51
24.5k
    }
52
}