wasmtime_environ/gc/
drc.rs

1//! Layout of Wasm GC objects in the deferred reference-counting collector.
2
3use super::*;
4
5/// The size of the `VMDrcHeader` header for GC objects.
6pub const HEADER_SIZE: u32 = 16;
7
8/// The align of the `VMDrcHeader` header for GC objects.
9pub const HEADER_ALIGN: u32 = 8;
10
11/// The offset of the length field in a `VMDrcArrayHeader`.
12pub const ARRAY_LENGTH_OFFSET: u32 = HEADER_SIZE;
13
14/// The layout of Wasm GC objects in the deferred reference-counting collector.
15#[derive(Default)]
16pub struct DrcTypeLayouts;
17
18impl GcTypeLayouts for DrcTypeLayouts {
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}