wasmtime_environ/gc/
null.rs

1//! Layout of Wasm GC objects in the  null garbage collector.
2
3use super::*;
4
5/// The size of the `VMNullHeader` header for GC objects.
6pub const HEADER_SIZE: u32 = 8;
7
8/// The align of the `VMNullHeader` header for GC objects.
9pub const HEADER_ALIGN: u32 = 8;
10
11/// The offset of the length field in a `VMNullArrayHeader`.
12pub const ARRAY_LENGTH_OFFSET: u32 = HEADER_SIZE;
13
14/// The layout of Wasm GC objects in the null collector.
15#[derive(Default)]
16pub struct NullTypeLayouts;
17
18impl GcTypeLayouts for NullTypeLayouts {
19    fn array_length_field_offset(&self) -> u32 {
20        ARRAY_LENGTH_OFFSET
21    }
22
23    fn array_layout(&self, ty: &WasmArrayType) -> GcArrayLayout {
24        common_array_layout(ty, HEADER_SIZE, HEADER_ALIGN, ARRAY_LENGTH_OFFSET)
25    }
26
27    fn struct_layout(&self, ty: &WasmStructType) -> GcStructLayout {
28        common_struct_layout(ty, HEADER_SIZE, HEADER_ALIGN)
29    }
30}