Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/environ/src/gc/null.rs
1693 views
1
//! Layout of Wasm GC objects in the null garbage collector.
2
3
use super::*;
4
5
/// The size of the `VMNullHeader` header for GC objects.
6
pub const HEADER_SIZE: u32 = 8;
7
8
/// The align of the `VMNullHeader` header for GC objects.
9
pub const HEADER_ALIGN: u32 = 8;
10
11
/// The offset of the length field in a `VMNullArrayHeader`.
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
/// The layout of Wasm GC objects in the null collector.
21
#[derive(Default)]
22
pub struct NullTypeLayouts;
23
24
impl GcTypeLayouts for NullTypeLayouts {
25
fn array_length_field_offset(&self) -> u32 {
26
ARRAY_LENGTH_OFFSET
27
}
28
29
fn exception_tag_instance_offset(&self) -> u32 {
30
EXCEPTION_TAG_INSTANCE_OFFSET
31
}
32
33
fn exception_tag_defined_offset(&self) -> u32 {
34
EXCEPTION_TAG_DEFINED_OFFSET
35
}
36
37
fn array_layout(&self, ty: &WasmArrayType) -> GcArrayLayout {
38
common_array_layout(ty, HEADER_SIZE, HEADER_ALIGN, ARRAY_LENGTH_OFFSET)
39
}
40
41
fn struct_layout(&self, ty: &WasmStructType) -> GcStructLayout {
42
common_struct_layout(ty, HEADER_SIZE, HEADER_ALIGN)
43
}
44
45
fn exn_layout(&self, ty: &WasmExnType) -> GcStructLayout {
46
common_exn_layout(ty, HEADER_SIZE, HEADER_ALIGN)
47
}
48
}
49
50