wasmer_compiler/types/
module.rs

1/*
2 * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)]
3 * on their own.
4 */
5#![allow(missing_docs)]
6
7//! Types for modules.
8use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
9#[cfg(feature = "enable-serde")]
10use serde::{Deserialize, Serialize};
11use std::sync::Arc;
12use wasmer_types::{
13    Features, LocalFunctionIndex, MemoryIndex, MemoryStyle, ModuleInfo, TableIndex, TableStyle,
14    entity::PrimaryMap,
15};
16
17/// The required info for compiling a module.
18///
19/// This differs from [`ModuleInfo`] because it have extra info only
20/// possible after translation (such as the features used for compiling,
21/// or the `MemoryStyle` and `TableStyle`).
22#[cfg_attr(feature = "enable-serde", derive(Deserialize, Serialize))]
23#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
24#[derive(Debug, Clone, PartialEq, Eq, RkyvSerialize, RkyvDeserialize, Archive)]
25#[rkyv(derive(Debug))]
26pub struct CompileModuleInfo {
27    /// The features used for compiling the module
28    pub features: Features,
29    /// The module information
30    pub module: Arc<ModuleInfo>,
31    /// The memory styles used for compiling.
32    ///
33    /// The compiler will emit the most optimal code based
34    /// on the memory style (static or dynamic) chosen.
35    pub memory_styles: PrimaryMap<MemoryIndex, MemoryStyle>,
36    /// The table plans used for compiling.
37    pub table_styles: PrimaryMap<TableIndex, TableStyle>,
38    /// The maximum stack allocation directly connected to each function itself
39    /// if tracked (does not include any potential function calls).
40    pub function_max_stack_usage: PrimaryMap<LocalFunctionIndex, Option<usize>>,
41}